diff --git a/django/forms/renderers.py b/django/forms/renderers.py index 20eaf265df..1fc4431302 100644 --- a/django/forms/renderers.py +++ b/django/forms/renderers.py @@ -1,11 +1,9 @@ import functools -import warnings from pathlib import Path from django.conf import settings from django.template.backends.django import DjangoTemplates from django.template.loader import get_template -from django.utils.deprecation import RemovedInDjango60Warning from django.utils.functional import cached_property from django.utils.module_loading import import_string @@ -69,41 +67,6 @@ class Jinja2(EngineMixin, BaseRenderer): return Jinja2 -# RemovedInDjango60Warning. -class DjangoDivFormRenderer(DjangoTemplates): - """ - Load Django templates from django/forms/templates and from apps' - 'templates' directory and use the 'div.html' template to render forms and - formsets. - """ - - def __init__(self, *args, **kwargs): - warnings.warn( - "The DjangoDivFormRenderer transitional form renderer is deprecated. Use " - "DjangoTemplates instead.", - RemovedInDjango60Warning, - stacklevel=2, - ) - super().__init__(*args, **kwargs) - - -# RemovedInDjango60Warning. -class Jinja2DivFormRenderer(Jinja2): - """ - Load Jinja2 templates from the built-in widget templates in - django/forms/jinja2 and from apps' 'jinja2' directory. - """ - - def __init__(self, *args, **kwargs): - warnings.warn( - "The Jinja2DivFormRenderer transitional form renderer is deprecated. Use " - "Jinja2 instead.", - RemovedInDjango60Warning, - stacklevel=2, - ) - super().__init__(*args, **kwargs) - - class TemplatesSetting(BaseRenderer): """ Load templates using template.loader.get_template() which is configured diff --git a/docs/ref/forms/renderers.txt b/docs/ref/forms/renderers.txt index f52534651a..de9a195949 100644 --- a/docs/ref/forms/renderers.txt +++ b/docs/ref/forms/renderers.txt @@ -109,12 +109,6 @@ If you want to render templates with customizations from your :setting:`TEMPLATES` setting, such as context processors for example, use the :class:`TemplatesSetting` renderer. -.. class:: DjangoDivFormRenderer - -.. deprecated:: 5.0 - -The alias of :class:`DjangoTemplates`. - ``Jinja2`` ---------- @@ -131,12 +125,6 @@ templates for widgets that don't have any, you can't use this renderer. For example, :mod:`django.contrib.admin` doesn't include Jinja2 templates for its widgets due to their usage of Django template tags. -.. class:: Jinja2DivFormRenderer - -.. deprecated:: 5.0 - -The alias of :class:`Jinja2`. - ``TemplatesSetting`` -------------------- diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt index 87ac8de60f..7d64f24bfa 100644 --- a/docs/releases/6.0.txt +++ b/docs/releases/6.0.txt @@ -257,6 +257,9 @@ to remove usage of these features. * Support for passing positional arguments to ``BaseConstraint`` is removed. +* The ``DjangoDivFormRenderer`` and ``Jinja2DivFormRenderer`` transitional form + renderers are removed. + See :ref:`deprecated-features-5.1` for details on these changes, including how to remove usage of these features. diff --git a/tests/forms_tests/tests/test_renderers.py b/tests/forms_tests/tests/test_renderers.py index 3c1d8bb8ea..3e973ad8fc 100644 --- a/tests/forms_tests/tests/test_renderers.py +++ b/tests/forms_tests/tests/test_renderers.py @@ -3,14 +3,11 @@ import unittest from django.forms.renderers import ( BaseRenderer, - DjangoDivFormRenderer, DjangoTemplates, Jinja2, - Jinja2DivFormRenderer, TemplatesSetting, ) -from django.test import SimpleTestCase, ignore_warnings -from django.utils.deprecation import RemovedInDjango60Warning +from django.test import SimpleTestCase try: import jinja2 @@ -56,31 +53,3 @@ class Jinja2Tests(SharedTests, SimpleTestCase): class TemplatesSettingTests(SharedTests, SimpleTestCase): renderer = TemplatesSetting - - -class DeprecationTests(SimpleTestCase): - def test_django_div_renderer_warning(self): - msg = ( - "The DjangoDivFormRenderer transitional form renderer is deprecated. Use " - "DjangoTemplates instead." - ) - with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx: - DjangoDivFormRenderer() - self.assertEqual(ctx.filename, __file__) - - def test_jinja2_div_renderer_warning(self): - msg = ( - "The Jinja2DivFormRenderer transitional form renderer is deprecated. Use " - "Jinja2 instead." - ) - with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx: - Jinja2DivFormRenderer() - self.assertEqual(ctx.filename, __file__) - - @ignore_warnings(category=RemovedInDjango60Warning) - def test_deprecation_renderers_can_be_instantiated(self): - tests = [DjangoDivFormRenderer, Jinja2DivFormRenderer] - for cls in tests: - with self.subTest(renderer_class=cls): - renderer = cls() - self.assertIsInstance(renderer, cls)