1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #32339 -- Deprecated transitional form renderers.

This commit is contained in:
Mariusz Felisiak
2023-01-18 11:08:39 +01:00
committed by GitHub
parent 3bbe22dafc
commit b209518089
6 changed files with 51 additions and 31 deletions

View File

@@ -1,9 +1,11 @@
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
@@ -64,6 +66,7 @@ class Jinja2(EngineMixin, BaseRenderer):
return Jinja2
# RemovedInDjango60Warning.
class DjangoDivFormRenderer(DjangoTemplates):
"""
Load Django templates from django/forms/templates and from apps'
@@ -71,22 +74,29 @@ class DjangoDivFormRenderer(DjangoTemplates):
formsets.
"""
# RemovedInDjango50Warning Deprecate this class in 5.0 and remove in 6.0.
form_template_name = "django/forms/div.html"
formset_template_name = "django/forms/formsets/div.html"
def __init__(self, *args, **kwargs):
warnings.warn(
"The DjangoDivFormRenderer transitional form renderer is deprecated. Use "
"DjangoTemplates instead.",
RemovedInDjango60Warning,
)
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.
"""
# RemovedInDjango50Warning Deprecate this class in 5.0 and remove in 6.0.
form_template_name = "django/forms/div.html"
formset_template_name = "django/forms/formsets/div.html"
def __init__(self, *args, **kwargs):
warnings.warn(
"The Jinja2DivFormRenderer transitional form renderer is deprecated. Use "
"Jinja2 instead.",
RemovedInDjango60Warning,
)
super.__init__(*args, **kwargs)
class TemplatesSetting(BaseRenderer):