Django's URL regex engine is failing

2019-08-27 19:53发布

问题:

Django's URL regex engine is failing and I have no idea why. Even my sanity checks are failing horribly.

Here's my urls.py:

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

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

I get this 404 error:

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.

when I visit

http://[ip address]/a

And it's hosted on Django 1.5.2 with Python 2.7.3 on Ubuntu 12.04 behind nginx if that info is relevant.

回答1:

Here's a clue: The current URL, , didn't match any of these.

It should say: The current URL, http://[ip address]/a, didn't match any of these.

So the dispatcher isn't getting the request url.

Take a look at this solution:
Django + NGINX URL Problem