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')),
...
]