Add login page

This commit is contained in:
Lucas Schumacher 2024-05-25 21:20:58 -04:00
parent 6f64fbb092
commit 81599a9bde
3 changed files with 43 additions and 0 deletions

View File

@ -123,3 +123,5 @@ STATIC_URL = 'static/'
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
LOGIN_REDIRECT_URL = '/polls'

View File

@ -23,4 +23,5 @@ urlpatterns = [
path('polls/', include('polls.urls')), path('polls/', include('polls.urls')),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', include('django.contrib.auth.urls')),
] ]

View File

@ -0,0 +1,40 @@
{% extends "base.html" %}
{% block title %}Login{% endblock %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>Your account doesn't have access to this page. To proceed,
please login with an account that has access.</p>
{% else %}
<p>Please login to see this page.</p>
{% endif %}
{% endif %}
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
<input type="submit" value="login">
<input type="hidden" name="next" value="{{ next }}">
</form>
{# Assumes you set up the password_reset view in your URLconf #}
<p><a href="{% url 'password_reset' %}">Lost password?</a></p>
{% endblock %}