[Answer]-Not able to get a hyperlinked field in django-rest-framework

1👍

You need to rename split to splits on your TransactionSerializer.

Right now, you have split defined as the HyperlinkedRelatedField you are looking for. You are not including split in the fields tuple within the serializer metadata, so it is not being included in the output. Once you rename it to splits, it will be included in the output correctly and use the right relationship to generate the links.

Without the rename, currently the serializer is auto-generating the splits field as a PrimaryKeyRelatedField. This is why you are getting integers as the output instead of the links you were expecting.

Leave a comment