1👍
api
is full match for regular expression [\w\-]+
using in ‘userprofiles.urls’. So when you type http://localhost:8000/api/
Django returns first found urlpattern which is url(r'^', include('userprofiles.urls'))
. Try to swap lines:
url(r'^pacientes/', include('userprofiles.urls', namespace='pacientes')),
# Patients url
url(r'^api/', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
url(r'^', include('userprofiles.urls')),
1👍
The order in which you define your URLs matter. Django tries to match your URL against every pattern until one of them matches.
Note that you included this line:
url(r'^', include('userprofiles.urls')),
before:
url(r'^api/', include(router.urls)),
which wasn’t a problem because the first pattern to match was the latter.
However, when you added the PatientDetail
view URL pattern:
url(r'^(?P<slug>[\w\-]+)/$', PatientDetail.as_view(), name='patient_detail')
/api/
was a match. Thus, the PatientDetail
view was called and your 404 error happened because no patient was found with username api, not because the URL was not found.
- [Answered ]-Add warning message in django-rest-framework
- [Answered ]-Xlsxwriter consuming too much memory and process gets killed
- [Answered ]-Why is my Python Django logging file empty when my console log is not?
- [Answered ]-Stripe – 'exp_month' parameter should be an integer (instead, is 02 ) in Django View
- [Answered ]-Testing with Django: how to display all characters when using assertEqual with json object?
Source:stackexchange.com