From b9013c4eb38a8e9b00a10c2187844f5f482810be Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Fri, 8 Oct 2021 11:21:05 +0200 Subject: [PATCH] Use Django Crispy forms --- accounts/templates/accounts/registration.html | 23 ++++++++++++++----- photo21/settings.py | 4 ++++ photo21/templates/registration/login.html | 10 +++----- .../registration/password_change_form.html | 4 ++-- .../registration/password_reset_confirm.html | 6 ++--- .../registration/password_reset_form.html | 6 ++--- requirements.txt | 1 + 7 files changed, 33 insertions(+), 21 deletions(-) diff --git a/accounts/templates/accounts/registration.html b/accounts/templates/accounts/registration.html index c62b66e..ba48e03 100644 --- a/accounts/templates/accounts/registration.html +++ b/accounts/templates/accounts/registration.html @@ -1,9 +1,20 @@ {% extends "base.html" %} +{% comment %} +SPDX-License-Identifier: GPL-2.0-or-later +{% endcomment %} +{% load i18n crispy_forms_tags %} +{% block title %}{% trans "Sign up" %}{% endblock %} + {% block content %} -

Création d'utilisateur

-
{% csrf_token %} - {{ form.as_p }} -
- -
+
+

+ {% trans "Sign up" %} +

+
+
{% csrf_token %} + {{ form|crispy }} + +
+
+
{% endblock %} \ No newline at end of file diff --git a/photo21/settings.py b/photo21/settings.py index b5ee4fd..b263fd8 100644 --- a/photo21/settings.py +++ b/photo21/settings.py @@ -41,6 +41,7 @@ INSTALLED_APPS = [ 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', + 'crispy_forms', 'photologue_custom', 'photologue', 'accounts', @@ -163,5 +164,8 @@ SESSION_COOKIE_AGE = 60 * 60 * 3 # Use only one Django Sites SITE_ID = 1 +# use Bootstrap forms +CRISPY_TEMPLATE_PACK = 'bootstrap4' + # Photologue PHOTOLOGUE_GALLERY_SAMPLE_SIZE = 1 diff --git a/photo21/templates/registration/login.html b/photo21/templates/registration/login.html index ac23d00..bf5d5f0 100644 --- a/photo21/templates/registration/login.html +++ b/photo21/templates/registration/login.html @@ -2,13 +2,9 @@ {% comment %} SPDX-License-Identifier: GPL-2.0-or-later {% endcomment %} -{% load i18n static %} +{% load i18n crispy_forms_tags %} {% block title %}{% trans "Log in" %}{% endblock %} -{% block extracss %} - -{% endblock %} - {% block content %}

@@ -33,8 +29,8 @@ SPDX-License-Identifier: GPL-2.0-or-later {% endif %}
{% csrf_token %} - {{ form }} - + {{ form|crispy }} + {% trans 'Forgotten your password or username?' %}
diff --git a/photo21/templates/registration/password_change_form.html b/photo21/templates/registration/password_change_form.html index f00698a..d74c762 100644 --- a/photo21/templates/registration/password_change_form.html +++ b/photo21/templates/registration/password_change_form.html @@ -2,7 +2,7 @@ {% comment %} SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} -{% load i18n %} +{% load i18n crispy_forms_tags %} {% block content %}
@@ -12,7 +12,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% csrf_token %}

{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}

- {{ form }} + {{ form|crispy }}
diff --git a/photo21/templates/registration/password_reset_confirm.html b/photo21/templates/registration/password_reset_confirm.html index 9719cf6..dd41889 100644 --- a/photo21/templates/registration/password_reset_confirm.html +++ b/photo21/templates/registration/password_reset_confirm.html @@ -2,7 +2,7 @@ {% comment %} SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} -{% load i18n %} +{% load i18n crispy_forms_tags %} {% block content %}
@@ -13,8 +13,8 @@ SPDX-License-Identifier: GPL-3.0-or-later {% if validlink %}

{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}

{% csrf_token %} - {{ form }} - + {{ form|crispy }} +
{% else %}

diff --git a/photo21/templates/registration/password_reset_form.html b/photo21/templates/registration/password_reset_form.html index f419ff7..9a6a15c 100644 --- a/photo21/templates/registration/password_reset_form.html +++ b/photo21/templates/registration/password_reset_form.html @@ -2,7 +2,7 @@ {% comment %} SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} -{% load i18n %} +{% load i18n crispy_forms_tags %} {% block content %}

@@ -14,8 +14,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% csrf_token %} - {{ form }} - + {{ form|crispy }} +
diff --git a/requirements.txt b/requirements.txt index 4d7394d..01d4671 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ Django~=2.2.20 django-photologue~=3.13 django-taggit~=1.5.1 +django-crispy-forms~=1.7