【问题标题】:problem in decoupling urls.py , while following a tutorial of django解耦 urls.py 的问题,同时遵循 django 的教程
【发布时间】:2011-02-06 21:28:18
【问题描述】:

http://docs.djangoproject.com/en/dev/intro/tutorial03/

我在步骤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

【问题讨论】:

  • 你能把urls.py贴在这里吗?

标签: django url jython django-urls


【解决方案1】:

检查您的正则表达式语法。特别是,看看您是否在模式开头的? 之前缺少左括号,如

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

以上内容应为

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

改为。

(解释:“没有什么可重复的”是由于? 正则表达式运算符出现的正则表达式错误,它前面没有可以合理附加的东西。(?P&lt;...&gt;...) 中的? 是特殊处理,但如果你忘记了左括号,正则表达式引擎会以常规方式处理?,这在^之后没有任何意义。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-07
    • 1970-01-01
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    相关资源
    最近更新 更多