【发布时间】:2014-03-23 08:25:05
【问题描述】:
我有以下 urlpatterns:
urlpatterns = patterns('',
url(r'^$', 'opeiaa.views.home', name='home'),
url(r'^store/$', 'opeiaa.views.store', name='store'),
url(r'^resume/$', 'opeiaa.views.resume', name='resume'),
url(r'^contact/$', 'opeiaa.views.contact', name='contact'),
url(r'^gallery/', include('gallery.urls')),
url(r'^admin/', include(admin.site.urls)),
)
...并且正在使用这种模板标签:
<a class='nav-link' href='{% url 'contact' %}'>Contact</a>
URL 在页面中呈现为http://localhost:8000/contact/。一切正常,使用./manage.py runserver 进行测试时...
...但随后我运行./manage.py runfcgi - 然后当我导航到联系人页面时,导航中的 URL 指向 http://localhost:8000/contact/contact/!我尝试在开头添加一个斜杠以使 URL 成为绝对 URL,但没有它,URL 似乎是绝对的。
我使用 nginx 作为前端,相关配置如下:
location / {
include fastcgi_params;
fastcgi_pass unix:/tmp/django.sock;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
我正在使用 Django 1.6 和 Python 2.7.4。有人有什么见解吗?
【问题讨论】: