Django
- 1 ответ
- 0 вопросов
1
Вклад в тег
username = request.POST['username']
password = request.POST['password']
user = auth.authenticate(username=username, password=password)
if user is not None:
auth.login(request, user)
return HttpResponseRedirect(reverse('myblog:index'))
<form action="{% url 'users:autho' %}" method="post" id="login-form">
{% csrf_token %}
{% if form.non_field_errors %}
<p>{{ form.non_field_errors }}</p>
{% endif %}
{% for item in form %}
<label for="{{ item.id_for_label }}">{{ item.label }}</label>
{{ item }}
{% endfor %}
<button type="submit">Войти</button>
</form>