Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django Url NoReverseMatch_Python_Regex_Django_Urlconf - Fatal编程技术网

Python Django Url 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

我正在尝试创建一个url,其中包含给定模型的slug和pk。但是,当我尝试此操作时,我遇到了NoReverseMatch错误

网址:

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”),

谢谢您的快速回答。