使用 Django 标记时 URL 中的未知说明符
您好,我收到以下错误;
error at /
unknown specifier: ?P[
这就是我的 URLS 文件的样子;
urlpatterns = patterns('mainpage.views',
(r'^$', 'index'),
(r'^post/(?P<id>\d+)/$', 'post'),
(r'^projects/$', 'projects'),
(r'^about/$', 'about'),
(r'^tags/$', 'tags'),
(r'^tag/(?P[-_A-Za-z0-9]+)/$', 'with_tag'),
(r'^tag/(?P[-_A-Za-z0-9]+)/page/(?Pd+)/$', 'with_tag'),
(r'^comments/$', include('django.contrib.comments.urls'))
视图名称为 with_tag 的两个 URL 是违规 URL。我正在关注本教程;
让标记在我的网站上正常工作。我正在使用 Django 标记 1.3.1 和 Python 2.7。
谁能告诉我我对 URLS.py 文件做错了什么?我正在按书本复制教程,但与教程中使用的设置相比,我的设置一定有不同吗?
Hi I am getting the following error;
error at /
unknown specifier: ?P[
This is what my URLS file looks like;
urlpatterns = patterns('mainpage.views',
(r'^
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
, 'index'),
(r'^post/(?P<id>\d+)/
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
, 'post'),
(r'^projects/
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
, 'projects'),
(r'^about/
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
, 'about'),
(r'^tags/
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
, 'tags'),
(r'^tag/(?P[-_A-Za-z0-9]+)/
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
, 'with_tag'),
(r'^tag/(?P[-_A-Za-z0-9]+)/page/(?Pd+)/
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
, 'with_tag'),
(r'^comments/
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
, include('django.contrib.comments.urls'))
The two URLS with a view name of with_tag are the offending urls. I am following this tutorial;
to get tagging working on my site. I am using Django-tagging 1.3.1 and Python 2.7.
Can anyone tell me what I am doing wrong to my URLS.py file please? I am copying the tutorial by the book but there must be something different in my set up compared to the set up used in the tutorial?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与 django 标记无关,这是一个正则表达式语法错误。
?P
表示命名组,并且需要在其后添加名称:?P
。因此,要么向您的组添加名称,要么对它们进行编号(即删除?P
部分)。This is not related to django-tagging, it's a regex syntax error.
?P
indicates a named group, and requires a name after it:?P<foo>
. So, either add names to your groups, or make them numbered (i.e. remove?P
part).