django url.py出错?

时间:2010-03-29 02:30:16

标签: django

我是django的新手。我尝试练习并运行wiki应用程序(我在http://showmedo.com/videotutorials/video?name=1100000&fromSeriesID=110">Learn django找到了教程),在url.py文件中我写了以下网址...

urlpatterns = patterns('',    
    (r'^wikicamp/(?p<page_name>[^/]+)/edit/$','wikiapp.wiki.views.edit_page'),
    (r'^wikicamp/(?p<page_name>[^/]+)/save/$','wikiapp.wiki.views.save_page'),
    (r'^wikicamp/(?p<page_name>[^/]+)/$','wikiapp.wiki.views.view_page'),
)

但是我无法理解错误。

sre_Constants.error:Unexpected end of pattern.
  (r'^wikicamp/(?p<page_name>[^/]+)/$','wikiapp.wiki.views.view_page'), 

我使用Django-1.0.2-final.tar.gz

1 个答案:

答案 0 :(得分:6)

您需要使用大写P来捕获命名的正则表达式组:

urlpatterns = patterns('',    
    (r'^wikicamp/(?P<page_name>[^/]+)/edit/$','wikiapp.wiki.views.edit_page'),
    (r'^wikicamp/(?P<page_name>[^/]+)/save/$','wikiapp.wiki.views.save_page'),
    (r'^wikicamp/(?P<page_name>[^/]+)/$','wikiapp.wiki.views.view_page'),
)