class EmployeeSerializer(serializers.HyperlinkedModelSerializer):
url = serializers.SerializerMethodField('get_employee_detail_url')
def get_employee_detail_url(self, obj):
# generate the URL for the composite key
...
return composite_key_url
This worked fine in version 2.3.4 but fails in 2.3.5. HyperlinkedModelSerializer.__init__ has been modified and now it overwrites any custom url field with a HyperlinkedIdentityField.
So...
Is there an alternative way of overriding the URL field? Should I think about subclassing HyperlinkedModelSerializer? Or would it be acceptable to modify the initializer to check if self.fields['url'] has already been set before setting it to be the HyperlinkedIdentityField?
Thanks!