From 49bf9465d76644947da7b88091467168359548db Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 11 Oct 2021 13:46:19 +0200 Subject: [PATCH] Show Django messages --- photo21/settings.py | 10 ++++++++++ photo21/templates/base.html | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/photo21/settings.py b/photo21/settings.py index 1fcfcec..3dcdc22 100644 --- a/photo21/settings.py +++ b/photo21/settings.py @@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/ import os from django.utils.translation import gettext_lazy as _ +from django.contrib.messages import constants as messages # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -190,6 +191,15 @@ SESSION_COOKIE_AGE = 60 * 60 * 3 # Use only one Django Sites SITE_ID = 1 +# Django message +MESSAGE_TAGS = { + messages.DEBUG: 'alert-secondary', + messages.INFO: 'alert-info', + messages.SUCCESS: 'alert-success', + messages.WARNING: 'alert-warning', + messages.ERROR: 'alert-danger', +} + # Allauth configuration ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = "mandatory" diff --git a/photo21/templates/base.html b/photo21/templates/base.html index 2b48942..2bc7a99 100644 --- a/photo21/templates/base.html +++ b/photo21/templates/base.html @@ -87,6 +87,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
+ {% for message in messages %} + + {% endfor %} {% block content %}

Default content...

{% endblock %}