项目级别urls.py
urlpatterns += [
url(r'^machines/api/', include('core.urls')),
url(r'', include('apps.api.urls')),
url(r'^machines', include('apps.machines.urls')),]
应用级别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()),]
当我击中时 http://localhost:8000/machines/api/groups/add
它正在调用GroupList
视图而不是GroupCreate
。
我没有理由说明为什么会这样?
答案 0 :(得分:1)
当前网址列表在以GroupList
开头的每个网址上触发group/
。您应该在GroupList模式的末尾添加$
以限制GroupList仅使用group
触发的网址:
url(r'^group/$', core_view.GroupList.as_view()),
url(r'^groups/add/', core_view.GroupCreate.as_view()),]