我正在使用Django 2.2和python3。登录时,我得到:
TypeError at /accounts/login/$
__init__() takes 1 positional argument but 2 were given
请找到我的login.html代码:
{% extends 'blog/base.html' % }
{% block content %}
<div class="jumbotron">
<h2>Please Login:</h2>
<h3>(Must be SuperUser, please check with the site admin)</h3>
{% if form.errors %}
<p>Your Username and password didn''t match! Please try again. </p>
{% endif %}
<form action="{% url 'login' %}" method="POST">
{% csrf_token %}
{{% form.as_p %}}
<input type="submit" class="btn btn-btn-primary" value="Login">
<input type="hidden" name="next" value="{{next}}">
</form>
</div>
{% endblock %}
Urls.py的代码:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('blog.urls')),
path('accounts/login/$',views.LoginView,name='login'),
path('accounts/logout/$',views.LogoutView,name='logout',kwargs={'next_page':'/'})
]