我正在为一个在Nginx服务器上运行的Django站点设置登录系统。我正在收到以下调试404页面:
Using the URLconf defined in it.urls, Django tried these URL patterns, in this order:
^admin/
^login/ [name='main_login']
^$ [name='index']
^laptops/
^assets/
^mardes/
^users/
^jobs/
^static\/(?P<path>.*)$
The current URL, account/login/, didn't match any of these.
这似乎是使用旧版本的it.urls文件;目前的情况如下:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls) ),
url(r'^account/', include('account.urls', namespace='account'), name='account' ),
url(r'^laptops/', include('laptops.urls', namespace='laptops') ),
url(r'^assets/', include('assets.urls', namespace='assets') ),
url(r'^mardes/', include('mardes.urls', namespace='mardes') ),
url(r'^users/', include('users.urls', namespace='users') ),
url(r'^jobs/', include('jobs.urls', namespace='jobs') ),
url(r'^', TemplateView.as_view(template_name='it/index.html'), name='index' ),
) + staticfiles_urlpatterns()
正如您所看到的,没有r'^ login /'模式。
我在settings.py文件中将LOGIN_URL设置为'/ account / login /',但@login_required装饰器正在加载'/ login /'。当我在@login_required调用中指定login_url ='/ account / login'时,也会忽略新的URL。
我重新启动了Nginx(通过启动和停止,并运行'restart'),这没有什么不同。我还在nginx.conf文件中设置了“sendfile = off”。我猜测存储缓存(re:How to clear the cache of nginx?)。
如果您需要更多详细信息,请与我们联系。