from django.contrib.auth.models import User
from rest_framework import serializers

class UserSerializer(serializers.HyperlinkedModelSerializer):
    # Add explicit reverse lookup to profile
    profile = serializers.HyperlinkedRelatedField(
        view_name='api-profile',
        lookup_field='id',
        read_only=True
    )

    class Meta:
        model = User
        fields = ['url', 'id', 'username', 'email', 'profile']
        extra_kwargs = {
            'url': {'view_name': 'api-user', 'lookup_field': 'id'}
        }
