【发布时间】:2017-10-18 02:49:39
【问题描述】:
我收到此错误消息
Using the URLconf defined in esarcrm.urls, Django tried these URL patterns, in this order:
1. ^person/ duplicate_check/(?P<entity>)/(?P<full_name>)/?$
2. ^admin/
3. ^api/v1/
4. ^api/v1/authenticate/$ [name='api_authenticate']
5. ^static\/(?P<path>.*)$
6. ^media\/(?P<path>.*)$
The current path, person/duplicate_check/candidate/tom, didn't match any of these.
这里的空格请不要1. ^person/[SPACE]duplicate_check
我的项目/urls.py
urlpatterns = [
url(r'^person/', include('person.urls')),
url(r'^admin/', admin.site.urls),
url(r'^api/v1/', include(router.urls)),
url(r'^api/v1/authenticate/$', crm_views.ApiAuthenticateView.as_view(), name='api_authenticate'),
]
我的 app.urls
urlpatterns = [
url(r'duplicate_check/(?P<entity>)/(?P<full_name>)/?$', views.check_if_exist),
]
我的 app.views
@api_view(['GET'])
def check_if_exist(request, entity, first_name):
if entity == 'candidate':
candidates = person_models.Candidate.objects.filter(first_name=first_name)
serializer = person_serializers.CandidateMiniSerializer(candidates, many=True)
return Response(serializer.data)
我到底错过了什么?
【问题讨论】:
-
在 `urlpatterns` 在您的应用程序 url 中,您忘记输入
^像r^'duplicate_check...
标签: django django-rest-framework django-urls