2010-03-29 46 views
0

我是django新手。我試圖練習並運行wiki應用程序(我在http://showmedo.com/videotutorials/video?name=1100000 & fromSeriesID = 110「> Learn django)找到了教程,在url.py文件中,我編寫了以下URL。 ..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'), 
) 

但有errror,我無法理解。

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

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

回答

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