I have a model which is called GameProfile
, which is a one to one relation with User
model. I used HyperlinkedModelSerializer
across all m
If I'm understanding your question correctly, you want a url structure like so:
/api//
If that is the case, you should checkout the lookup_field
option. Link
You're Serializer class would look something like:
class GameProfileSerializer(serializers.HyperlinkedModelSerializer):
"""
"""
user_pk = serializers.Field(source='user.id')
class Meta:
model = GameProfile
lookup_field = 'user_pk' # Might have to use 'user__id'