Could not resolve URL for hyperlinked relationship using view name "xxx:api:xxx-detail". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field.
出现这种错误一般是没有在urls.py文件中添加一个namespace
做如下修改:
urlpatterns = [
...
url(r'^abc/', include('abc.urls')),
...
]
添加namespace
urlpatterns = [
...
url(r'^abc/', include('abc.urls', namespace='abc')),
...
]
本文介绍了一种常见的超链接关系无法解析的错误,并提供了解决方案。通常是因为未在urls.py文件中正确设置命名空间导致。通过添加正确的命名空间可以解决此问题。
4917

被折叠的 条评论
为什么被折叠?



