Closed
Description
Refer to: #904
There is no way currently to pass a custom lookup name of related_view
s to hyperlinked fields.
The below field should link to /entries/123/comments
instead of /entries/123/comments_hyperlinked
.
comments_hyperlinked = relations.HyperlinkedRelatedField(
related_link_view_name="entry-related",
related_link_url_kwarg="entry_pk",
self_link_view_name="entry-relationships",
many=True,
read_only=True,
source="comments",
)
Activity
sliverc commentedon Apr 20, 2021
This is in the example app like this but I wonder whether it makes any sense at all to define a related field to the same relationship twice on the same serializer: one hyperlinked and one as resource.
I haven't tested this but if the hyperlink is defined like the below it should actually work right?
If so my question would be what the use case is for referencing the same relation once hyperlinked and once a resource is?
sliverc commentedon Sep 23, 2021
I thought about this issue again and actually the url the hyperlinked related field produces is correct, the issue is though that the test
EntrySerializer
does not either add aincluded_serializers
orrelated_serializers
for the fieldcomments_hyperlinked
. So this is a issue in the configuration of the example app. As of #468 we are currently cleaning up all the tests and then the example app so this will be addressed there too. Therefore closing this issue.If I missed anything and this is actually a DJA and not a test issue please feel free to comment.