我的应用程序的网址如下所示:
(r'^admin/', include(admin.site.urls)),
(r'^contractManagement/login', 'django.contrib.auth.views.login', {'template_name': 'login.html'},()),
(r'^contractManagement/logout', 'contractManagement.contracts.views.logout_view'),
(r'^contractManagement/', 'contractManagement.contracts.views.index'),
(r'^accounts/profile/(?P<contract>[^/]+)/edit$', 'contractManagement.contracts.views.editContract'),
(r'^accounts/profile/(?P<contract>[^/]+)/$', 'contractManagement.contracts.views.viewContract'),
(r'^accounts/profile/$', 'contractManagement.contracts.views.loggedIn'),
(r'^accounts/profile/newContract$', 'contractManagement.contracts.views.addContract'),
(r'^accounts/profile/newClient$', 'contractManagement.contracts.views.addClient'),
(r'^accounts/profile/logout$', 'django.contrib.auth.views.logout', {'template_name': 'LoggedOut.html'},()),
我现在收到错误No Contract与给定查询匹配。这是404错误。我不知道为什么/accounts/profile/newContract/
的观点不需要合同。如果您还需要其他任何评论。
答案 0 :(得分:2)
按顺序处理Django URL模式。您的/accounts/profile/newContracts/
网址与您的r '^accounts/profile/(?P<contract>[^/]+)/$'
模式相匹配。
尝试将r'^accounts/profile/newContract$'
模式向上移动。 (并修复丢失的'错字')
但更重要的是,请确保您的网址方案不含糊不清。
答案 1 :(得分:0)
(R '^账户/简档/ newContract $' newContract - 没有s。 然后你去/ accounts / profile / newContracts。随着s结束 如果你对newContracts它将匹配这个网址: (r'^ accounts / profile /(?P [^ /] +)/ $','contractManagement.contracts.views.viewContract'), 并将寻找newContracts