Python Django Url NoReverseMatch
我正在尝试创建一个url,其中包含给定模型的slug和pk。但是,当我尝试此操作时,我遇到了NoReverseMatch错误 网址:Python Django Url NoReverseMatch,python,regex,django,urlconf,Python,Regex,Django,Urlconf,我正在尝试创建一个url,其中包含给定模型的slug和pk。但是,当我尝试此操作时,我遇到了NoReverseMatch错误 网址: urlpatterns = patterns('', # Blah Blah url(r'^dashboard/(?P<slug>[-\w]+])-by-(?P<pk>\d+)/$', WebsiteTemplateView.as_view(), name="websitedetail"), ) urlpatterns=p
urlpatterns = patterns('',
# Blah Blah
url(r'^dashboard/(?P<slug>[-\w]+])-by-(?P<pk>\d+)/$', WebsiteTemplateView.as_view(), name="websitedetail"),
)
urlpatterns=patterns(“”,
#废话
url(r'^dashboard/(?P[-\w]+])-由-(?P\d+/$),WebsiteTemplateView.as_view(),name=“websitedetail”),
)
错误:
NoReverseMatch: Reverse for 'websitedetail' with arguments '()' and keyword arguments '{'pk': 42, 'slug': u'when-you-talk-you-hardly-even-look-in-my-eyes'}' not found. 1 pattern(s) tried: ['dashboard/(?P<slug>[-\\w]+])-by-(?P<pk>\\d+)/$']
NoReverseMatch:websitedetail与参数“()”相反,关键字参数“{'pk':42,'slug':u'when-you-talk-you-know-event-look-in-my-eyes'}”未找到。已尝试1个模式:[“仪表板/(?P[-\\w]+])-由-(?P\\d+/$”]
提前感谢。移除
命名组中多余的方括号:
url(r'^dashboard/(?P<slug>[-\w]+)-by-(?P<pk>\d+)/$',
WebsiteTemplateView.as_view(), name="websitedetail"),
url(r'^dashboard/(?P[-\w]+)-by-(?P\d+/$),
WebsiteTemplateView.as_view(),name=“websitedetail”),
谢谢您的快速回答。