我有以下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>
网址在http://localhost:8000/contact/
页面中呈现。使用./manage.py runserver
进行测试时,一切正常......
...但我运行./manage.py runfcgi
- 然后当我导航到联系页面时,导航中的网址指向http://localhost:8000/contact/contact/
!我已经尝试在开头设置斜杠以使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&amp; Python 2.7.4。有人有任何见解吗?
答案 0 :(得分:0)
SCRIPT_NAME
之前设置了include fastcgi_params
!
最终的工作配置代码段:
location / {
include fastcgi_params;
fastcgi_param SCRIPT_NAME "";
fastcgi_pass unix:/tmp/django.sock;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}