I have a model which is called GameProfile
, which is a one to one relation with User
model. I used HyperlinkedModelSerializer
across all m
Assuming your GameProfile
model looks like:
class GameProfile(models.Model)
user = models.OneToOneField('User')
The serializer will be:
class GameProfileSerializer(serializers.HyperlinkedModelSerializer):
user_id = serializers.Field(source='user.id')
class Meta:
model = GameProfile
Set the .lookup_field
attribute on the view correctly:
lookup_field = 'user_id'
Url will be:
/gameprofile/