2010-04-12 77 views
0

http://docs.djangoproject.com/en/dev/intro/tutorial03/問題解耦urls.py,而以下的django

的教程我在步驟Decoupling the URLconfs其中教程說明了如何分離urls.py。在做到完全是這樣的,我得到以下錯誤 -

error at /polls/1/ 
nothing to repeat 
Request Method: GET 
Request URL: http://localhost:8000/polls/1/ 
Exception Type: error 
Exception Value:  
nothing to repeat 
Exception Location: C:\jython2.5.1\Lib\re.py in _compile, line 241 
Python Executable: C:\jython2.5.1\jython.bat 
Python Version: 2.5.1 
Python Path: ['E:\\Programming\\Project\\django_app\\mysite', 'C:\\jython2.5.1\\Lib\\site-packages\\setuptools-0.6c11-py2.5.egg', 'C:\\jython2.5.1\\Lib', '__classpath__', '__pyclasspath__/', 'C:\\jython2.5.1\\Lib\\site-packages'] 
Server time: Mon, 12 Apr 2010 12:02:56 +0530 
+0

你可以在這裏粘貼urls.py嗎? – zsong 2010-04-12 06:44:47

回答

6

檢查您的正則表達式語法。特別是,看看你是否錯過了?朝着模式開始前左括號,如

r'^?P<poll_id>\d+)/$' 
#^note the missing parenthesis 

以上應閱讀

r'^(?P<poll_id>\d+)/$' 

代替。

(一種解釋:「沒有重複」是其產生是由於發生的?正則表達式運算符的地方不被一些東西,它能夠明智地附加到(?P<...>...)?是經過特殊處理的前面有一個正則表達式的錯誤,但如果。你忘了左括號,正則引擎將以普通方式對待?,這在^之後沒有任何意義。)

+0

那解決了這個問題:) .. thanx – 2010-04-12 06:57:43