在遵循 django 教程时解耦 urls.py 的问题

发布于 2024-08-28 16:28:48 字数 980 浏览 7 评论 0原文

http://docs.djangoproject.com/en/dev/intro/tutorial03/< /a>

我正在执行解耦 URLconf 其中教程说明了如何解耦 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

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

I was at the step Decoupling the URLconfs where the tutorial illustrates how to decouple urls.py. On doing exactly what it says, i get the following error-

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一袭水袖舞倾城 2024-09-04 16:28:48

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

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

上面的内容所示

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

(解释:“无重复”是一个正则表达式错误,它是由于 ? 正则表达式运算符发生在其前面没有可以合理附加的内容而引起的。??(?P<...>...) 中的 code> 会被特殊处理,但是如果您忘记了左括号,正则表达式引擎将处理 ? 中的 ?常规方式,在 ^ 之后没有任何意义。)

# ^ note the missing parenthesis

上面的内容所示


(解释:“无重复”是一个正则表达式错误,它是由于 ? 正则表达式运算符发生在其前面没有可以合理附加的内容而引起的。??(?P<...>...) 中的 code> 会被特殊处理,但是如果您忘记了左括号,正则表达式引擎将处理 ? 中的 ?常规方式,在 ^ 之后没有任何意义。)

(解释:“无重复”是一个正则表达式错误,它是由于 ? 正则表达式运算符发生在其前面没有可以合理附加的内容而引起的。??(?P<...>...) 中的 code> 会被特殊处理,但是如果您忘记了左括号,正则表达式引擎将处理 ? 中的 ?常规方式,在 ^ 之后没有任何意义。)

# ^ note the missing parenthesis

上面的内容所示

(解释:“无重复”是一个正则表达式错误,它是由于 ? 正则表达式运算符发生在其前面没有可以合理附加的内容而引起的。??(?P<...>...) 中的 code> 会被特殊处理,但是如果您忘记了左括号,正则表达式引擎将处理 ? 中的 ?常规方式,在 ^ 之后没有任何意义。)

Check your regex syntax. In particular, see if you are missing an opening parenthesis before a ? towards the beginning of the pattern, as in

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

The above should read

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

instead.

(An explanation: "nothing to repeat" is a regex error which arises due to an ? regex operator occurring where it is not preceded by something which it can sensibly attach to. The ? in (?P<...>...) is treated specially, but if you forget the opening parenthesis, the regex engine will treat ? in the regular way, which makes no sense right after ^.)

# ^ note the missing parenthesis

The above should read


instead.

(An explanation: "nothing to repeat" is a regex error which arises due to an ? regex operator occurring where it is not preceded by something which it can sensibly attach to. The ? in (?P<...>...) is treated specially, but if you forget the opening parenthesis, the regex engine will treat ? in the regular way, which makes no sense right after ^.)

instead.

(An explanation: "nothing to repeat" is a regex error which arises due to an ? regex operator occurring where it is not preceded by something which it can sensibly attach to. The ? in (?P<...>...) is treated specially, but if you forget the opening parenthesis, the regex engine will treat ? in the regular way, which makes no sense right after ^.)

# ^ note the missing parenthesis

The above should read

instead.

(An explanation: "nothing to repeat" is a regex error which arises due to an ? regex operator occurring where it is not preceded by something which it can sensibly attach to. The ? in (?P<...>...) is treated specially, but if you forget the opening parenthesis, the regex engine will treat ? in the regular way, which makes no sense right after ^.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文