From b72463af58122ee9d655a79c7fe2aa2d84649336 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 29 Dec 2019 15:09:34 +0100 Subject: [PATCH] add authentication views --- chloro/phyll/templates/registration/login.html | 11 +++++++++++ chloro/settings.py | 2 ++ chloro/urls.py | 6 +++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 chloro/phyll/templates/registration/login.html diff --git a/chloro/phyll/templates/registration/login.html b/chloro/phyll/templates/registration/login.html new file mode 100644 index 0000000..2e89da4 --- /dev/null +++ b/chloro/phyll/templates/registration/login.html @@ -0,0 +1,11 @@ +{% extends "phyll/base.html" %} +{% load i18n %} + +{% block body %} +
+{% csrf_token %} +{{ form.as_p }} + + +
+{% endblock %} diff --git a/chloro/settings.py b/chloro/settings.py index 4ee2cfe..f3d06cd 100644 --- a/chloro/settings.py +++ b/chloro/settings.py @@ -89,6 +89,8 @@ AUTH_PASSWORD_VALIDATORS = [ {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',}, ] +LOGIN_REDIRECT_URL = '/' +LOGIN_URL = 'login' # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ diff --git a/chloro/urls.py b/chloro/urls.py index 032add7..d84a5e5 100644 --- a/chloro/urls.py +++ b/chloro/urls.py @@ -17,9 +17,13 @@ from django.conf import settings from django.conf.urls import include, url from django.conf.urls.static import static +from django.contrib.auth import views as auth_views from django.contrib.staticfiles.urls import staticfiles_urlpatterns -urlpatterns = [] +urlpatterns = [ + url(r'^accounts/login/$', auth_views.LoginView.as_view(), name='login'), + url(r'^accounts/logout/$', auth_views.LogoutView.as_view(), name='logout'), +] # static and media files urlpatterns += staticfiles_urlpatterns() -- 2.39.2