-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Could not resolve URL for hyperlinked relationship using view name" error message #3291
Comments
Okay, let's re-review the error message there. |
+1 I just left a message in another issue thread but I definitely agree. The hours spent on this problem myself are dozen, and I still don' get it right. |
None of my URLs use 'pk' but always some special identifiers such as '/api/(?P\d+)/$', or 'name' or whatever. And I couldn't disentangle this with lookup_field (and where? Meta? dedicated serializer?) and lookup_url_args? |
My bad, it was a typo in my URL view name. I managed to fix my bug. |
Last comment: the error message suggests that the reason why an error occurs is related to the model, or the lookup_field, while these two are certainly the first things to implement (and the first things to get right). What lead me in wrong directions is that other reasons could be the source of this error, not related to the model or the lookup_field. |
100% agree that it is a horrible error message to have to show to users.
Furthermore, command-line options to print URL configurations / serializers might also be helpful? |
It looks like excellent ideas. I'll have a look a bit more on the DRF code to try suggesting solutions, as soon as I can grab some time. |
Closing this off given that Closing this off given #3816 improves the namespacing issue. No doubt there's plenty of usability improvements we could make around handling hyperlinked URLs, but we can tackle them as specific issues if anyone has any specific improvements in mind. |
Just spent about 2 hours to find what it was. |
This is a message meaning that it couldn't be resolved. There are plenty reasons why this could fail and I don't think a way we can help more here. |
delete namespace helped me |
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: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 passingview_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.
The text was updated successfully, but these errors were encountered: