新手,调了一天了,还是没解决,请求大佬支援
报错内容
NoReverseMatch at /users/login/
Reverse for 'login' not found. 'login' is not a valid view function or pattern name.
Request Method: GET
Request URL: http://127.0.0.1:8000/users/login/
Django Version: 2.1.4
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'login' not found. 'login' is not a valid view function or pattern name.
Exception Location: /Users/wei/anaconda3/envs/opp/lib/python3.6/site-packages/django/urls/
resolvers.py in _reverse_with_prefix, line 622
Python Executable: /Users/wei/anaconda3/envs/opp/bin/python
Python Version: 3.6.7
Python Path:
['/Users/wei',
'/Users/wei/anaconda3/envs/opp/lib/python36.zip',
'/Users/wei/anaconda3/envs/opp/lib/python3.6',
'/Users/wei/anaconda3/envs/opp/lib/python3.6/lib-dynload',
'/Users/wei/anaconda3/envs/opp/lib/python3.6/site-packages']
Server time: Wed, 9 Jan 2019 07:30:40 +0000
login.html
{% extends "learning_logs/base.html" %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
<form action="{% url 'users:login' %}" method='post'>
{% csrf_token %}
{{ form.as_p }}
<button name="submit">log in</button>
<input type="hidden" name="next" value="{% url 'learning_logs:index' %}" />
</form>
<p>AAAAAAA</p>
{% endblock content %}
urls.pyfrom django.urls import path, re_path
from django.contrib.auth import views as auth_views
app_name = 'users'
urlpatterns = [
# 登录页面
# path('users/', auth_views.LoginView.as_view(template_name='users/login.html')),
path('users/login/', auth_views.LoginView.as_view(template_name='users/login.html')),
]
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/525399
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.