108
108

Reputation: 139

URL conflict in django1.8 and DRF 2.4.8

Project level urls.py

urlpatterns += [
url(r'^machines/api/', include('core.urls')),
url(r'', include('apps.api.urls')),
url(r'^machines', include('apps.machines.urls')),]

App level urls.py

urlpatterns = [
url(r'^user/edit/(?P<pk>[0-9]+)/$', core_view.ProfileEdit.as_view()),
url(r'^group/', core_view.GroupList.as_view()),
url(r'^groups/add/', core_view.GroupCreate.as_view()),]

when i hit http://localhost:8000/machines/api/groups/add

it is calling GroupList view instead of GroupCreate. I am not getting any reason why this is happening?

Upvotes: 2

Views: 108

Answers (1)

neverwalkaloner
neverwalkaloner

Reputation: 47354

Current url list triggered GroupList on each url started with group/. You should add $ at the end of GroupList pattern to limit url triggered by GroupList only with group:

url(r'^group/$', core_view.GroupList.as_view()),
url(r'^groups/add/', core_view.GroupCreate.as_view()),]

Upvotes: 1

Related Questions