新手,调了一天了,还是没解决,请求大佬支援
报错内容
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')),
]