From df6e26ee84ced8811d7180e993a8c434e34f4835 Mon Sep 17 00:00:00 2001
From: Sylvain Boissel
Date: Mon, 19 Aug 2024 14:59:32 +0200
Subject: [PATCH 7/9] Improve warnings
---
config/settings.py | 10 ++++++++--
dsfr/templatetags/dsfr_tags.py | 19 ++++++++++++-------
.../templates/example_app/doc_markdown.html | 8 ++++++++
.../templates/example_app/page_component.html | 9 +++++----
.../templates/example_app/page_form.html | 1 +
5 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/config/settings.py b/config/settings.py
index 69ae4dd57..ccc1f175d 100644
--- a/config/settings.py
+++ b/config/settings.py
@@ -13,6 +13,7 @@
from pathlib import Path
import os
from django import VERSION as DJANGO_VERSION
+import warnings
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -28,6 +29,13 @@
ALLOWED_HOSTS = []
+warnings.simplefilter("default")
+if DJANGO_VERSION < (4, 0):
+ warnings.warn(
+ "Support for Django < 4.0 will be deprecated in django-dsfr at the end of 2024.",
+ PendingDeprecationWarning,
+ stacklevel=3,
+ )
# Application definition
@@ -125,8 +133,6 @@
USE_I18N = True
-USE_L10N = True
-
USE_TZ = True
LANGUAGES = [
diff --git a/dsfr/templatetags/dsfr_tags.py b/dsfr/templatetags/dsfr_tags.py
index 9e361bcbc..81d3c1f77 100644
--- a/dsfr/templatetags/dsfr_tags.py
+++ b/dsfr/templatetags/dsfr_tags.py
@@ -26,17 +26,15 @@
register = template.Library()
-warnings.simplefilter("default")
-
# Check for obsolete parameters inside tags?
# Deprecated tags will always issue a warning
if (
hasattr(settings, "DSFR_CHECK_DEPRECATED_PARAMS")
and settings.DSFR_CHECK_DEPRECATED_PARAMS
):
- CHECK_DEPRECATED = True
+ CHECK_DEPRECATED_PARAMS = True
else:
- CHECK_DEPRECATED = False
+ CHECK_DEPRECATED_PARAMS = False
"""
Tags used in the "DSFR" templates.
@@ -1154,7 +1152,7 @@ def dsfr_table(*args, **kwargs) -> dict:
]
tag_data = parse_tag_args(args, kwargs, allowed_keys)
- if "extra_classes" in tag_data and CHECK_DEPRECATED:
+ if "extra_classes" in tag_data and CHECK_DEPRECATED_PARAMS:
extra_classes = tag_data["extra_classes"]
# Deprecated in DSFR 1.12
deprecated_layout_classes = [
@@ -1558,11 +1556,18 @@ def _render_alert_tag(message):
@register.inclusion_tag("dsfr/form_snippet.html", takes_context=True)
def dsfr_form(context: Context, form=None) -> dict:
"""
- Returns the HTML for a form snippet
+ Returns the HTML for a form snippet.
+
+
+
This tag is obsolete and it will be removed at the end of 2024.
+
+ Please directly include the form with {{ form }} (or the name of the form context variable if different).
+
+
```python
data_dict = {
- "form": an optionnal form to render instead of the form already present in context
+ "form": an optional form to render instead of the form already present in context
}
```
diff --git a/example_app/templates/example_app/doc_markdown.html b/example_app/templates/example_app/doc_markdown.html
index 16b754338..d2c423209 100644
--- a/example_app/templates/example_app/doc_markdown.html
+++ b/example_app/templates/example_app/doc_markdown.html
@@ -1,5 +1,6 @@
{% extends "example_app/base.html" %}
{% load static dsfr_tags %}
+
{% block content %}
Exemple de formulaire
From bfdbf4762b74ff5a7a7dd45c3d1ecc96eaf2b697 Mon Sep 17 00:00:00 2001
From: Sylvain Boissel
Date: Mon, 19 Aug 2024 15:00:52 +0200
Subject: [PATCH 8/9] Consistency
---
doc/forms.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/forms.md b/doc/forms.md
index da1444f56..b850a55a1 100644
--- a/doc/forms.md
+++ b/doc/forms.md
@@ -55,6 +55,6 @@ def __init__(self, *args, **kwargs):
## Utilisation
-La balise `{% dsfr_form %}` est maintenant dépréciée et sera retirée avant la fin de l’année 2024.
+La balise `{% dsfr_form %}` est maintenant dépréciée et sera retirée à la fin de l’année 2024.
Il faut donc remplacer les instances de `{% dsfr_form %}` par ``{{ form }}`` et `{% dsfr_form my_custom_form %}` par `{{ my_custom_form }}`.
From 26b81bbd2187b9cd502e2e166b4264d87c037851 Mon Sep 17 00:00:00 2001
From: Sylvain Boissel
Date: Mon, 19 Aug 2024 15:03:17 +0200
Subject: [PATCH 9/9] Add deprecation warning in the README file
---
README.rst | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.rst b/README.rst
index f732abf49..ef1f948d3 100644
--- a/README.rst
+++ b/README.rst
@@ -36,6 +36,8 @@ Note: Only supported versions of Django and Python are supported by this project
- `Python `_
- `Django `_
+Warning: Support for Django < 4.0 and Python < 3.10 will be removed at the end of 2024.
+
Quick start
-----------