1๐
โ
A HyperlinkedRelatedField
must have a source
that points at a related object on the model. You are looking for a HyperlinkedIdentityField
, which will give a link for the current object, similar to what a HyperlinkedModelSerializer
will do automatically for you.
class MovieSerializer(serializers.ModelSerializer):
link = serializers.HyperlinkedIdentityField(view_name='movie_detail')
class Meta:
model = Movie
fields = ( 'link', 'title', )
Source:stackexchange.com