【发布时间】:2018-06-28 23:33:09
【问题描述】:
我对 Django 有疑问。实际上我想在我的新站点中创建一个登录面板,但是当我尝试编写地址时,调试器会响应我一个错误:
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/account/login
Using the URLconf defined in firmowa.urls, Django tried these URL patterns, in this order:
admin/
^account/
The current path, account/login, didn't match any of these.
我的firmowa.urls 是
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path(r'^account/', include('account.urls')),
]
而项目的urls.py是:
from django.urls import path
from . import views
urlpatterns = [
path(r'^login/$', views.user_login, name='login'),
]
我正在寻找几个小时后的解决方案,但仍然一无所获。
【问题讨论】:
-
在您的请求末尾添加斜杠:/account/login/
-
如果你在 Django 2.0 中使用
path功能,你不需要提供r'^account/',,只需path('account/', include('account.urls')),就足够了。登录网址相同。
标签: python django django-urls django-2.0