【问题标题】:Django's URL regex engine is failingDjango 的 URL 正则表达式引擎失败
【发布时间】:2013-08-25 18:15:15
【问题描述】:

Django 的 URL 正则表达式引擎失败了,我不知道为什么。甚至我的理智检查也失败了。

这是我的urls.py

from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
    url(r'^a', 'placemyorder.views.home', name='home'),
)

我得到这个 404 错误:

Page not found (404)
Request Method: GET
Request URL:    http://[ip address]/a/
Using the URLconf defined in placemyorder.urls, Django tried these URL patterns, in this order:
1. ^a [name='home']
The current URL, , didn't match any of these.

当我访问时

http://[ip address]/a

如果该信息相关,它托管在 Django 1.5.2 和 Python 2.7.3 上,位于 nginx 后面的 Ubuntu 12.04 上。

【问题讨论】:

  • 你试过r'^a/$'吗?
  • 是的,我试过了,结果相同
  • 你的根 urls.py 是什么样的?请粘贴代码,而不是代码截图
  • 完全相同的结果1. ^a$ [name='home']
  • 等一下,这是一条线索The current URL, , didn't match any of these. 它应该是The current URL, http://[ip address]/a, didn't match any of these. 所以调度程序没有得到请求的url。会不会是 nginx 的问题?

标签: regex django nginx django-urls


【解决方案1】:

这里有一个线索:The current URL, , didn't match any of these.

应该说:The current URL, http://[ip address]/a, didn't match any of these.

所以调度程序没有得到请求 url。

看看这个解决方案:
Django + NGINX URL Problem

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-04
    • 2011-03-22
    • 2013-07-26
    • 2014-07-08
    • 1970-01-01
    • 2018-04-24
    相关资源
    最近更新 更多