I have a DRF project where I’m trying to build an api using a
HyperlinkedModelSerializer (in combination with a ViewSet).
This is works fine for
GET requests, but for
POST requests, I can see the
HyperlinkedRelatedField requires the full url of the related field. I guess this is as expected, but I was hoping I could override this so a user of the api could just supply a value for the
lookup_field rather than the full url.
I’m a bit stuck on where to override this behaviour and was hoping someone could point me in the right direction. Would I create a “duplicate” ModelSerializer and override the POST in the viewset referencing the ModelSerializer as opposed to the HyperlinkedModelSerializer, or is this something I can simply override in HyperlinkedModelSerializer itself?
Thanks in advance!