Skip to content

"Could not resolve URL for hyperlinked relationship using view name" error message #3291

Closed
@graup

Description

@graup

I just spent an hour trying to hunt this down. I tried to have different Serializers depending on the action. The list should only list URLs to the detail view and the detail view have all the info. I always got this error:

Could not resolve URL for hyperlinked relationship using view name "collection-detail". You may have failed to include the related model in your API, or incorrectly configured the lookup_field attribute on this field.

I tried everything, from manually defining the HyperlinkedIdentityField to fiddling with the viewsets... At some point I had the idea to try including the namespace when passing view_name but couldn't get it to work still.
In the end I solved this with simply removing the namespace attribute from my URL patterns.

So, my suggestion is to add this as a possible solution to the error message. It might save humanity many hours of troubleshooting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions