mirror of
https://github.com/django/django.git
synced 2025-01-03 06:55:47 +00:00
Refs #15667 -- Added resetting default renderer when FORM_RENDERER is changed.
This commit is contained in:
parent
fe835c2355
commit
6ad0dbc8d9
@ -202,6 +202,14 @@ def static_finders_changed(*, setting, **kwargs):
|
|||||||
get_finder.cache_clear()
|
get_finder.cache_clear()
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(setting_changed)
|
||||||
|
def form_renderer_changed(*, setting, **kwargs):
|
||||||
|
if setting == "FORM_RENDERER":
|
||||||
|
from django.forms.renderers import get_default_renderer
|
||||||
|
|
||||||
|
get_default_renderer.cache_clear()
|
||||||
|
|
||||||
|
|
||||||
@receiver(setting_changed)
|
@receiver(setting_changed)
|
||||||
def auth_password_validators_changed(*, setting, **kwargs):
|
def auth_password_validators_changed(*, setting, **kwargs):
|
||||||
if setting == "AUTH_PASSWORD_VALIDATORS":
|
if setting == "AUTH_PASSWORD_VALIDATORS":
|
||||||
|
@ -1502,11 +1502,17 @@ Overridden settings Data reset
|
|||||||
================================= ========================
|
================================= ========================
|
||||||
USE_TZ, TIME_ZONE Databases timezone
|
USE_TZ, TIME_ZONE Databases timezone
|
||||||
TEMPLATES Template engines
|
TEMPLATES Template engines
|
||||||
|
FORM_RENDERER Default renderer
|
||||||
SERIALIZATION_MODULES Serializers cache
|
SERIALIZATION_MODULES Serializers cache
|
||||||
LOCALE_PATHS, LANGUAGE_CODE Default translation and loaded translations
|
LOCALE_PATHS, LANGUAGE_CODE Default translation and loaded translations
|
||||||
STATIC_ROOT, STATIC_URL, STORAGES Storages configuration
|
STATIC_ROOT, STATIC_URL, STORAGES Storages configuration
|
||||||
================================= ========================
|
================================= ========================
|
||||||
|
|
||||||
|
.. versionchanged:: 5.1
|
||||||
|
|
||||||
|
Resetting the default renderer when the ``FORM_RENDERER`` setting is
|
||||||
|
changed was added.
|
||||||
|
|
||||||
Isolating apps
|
Isolating apps
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -5145,7 +5145,6 @@ class OverrideTests(SimpleTestCase):
|
|||||||
class Person(Form):
|
class Person(Form):
|
||||||
first_name = CharField()
|
first_name = CharField()
|
||||||
|
|
||||||
get_default_renderer.cache_clear()
|
|
||||||
t = Template("{{ form }}")
|
t = Template("{{ form }}")
|
||||||
html = t.render(Context({"form": Person()}))
|
html = t.render(Context({"form": Person()}))
|
||||||
expected = """
|
expected = """
|
||||||
@ -5153,14 +5152,12 @@ class OverrideTests(SimpleTestCase):
|
|||||||
<input type="text" name="first_name" required id="id_first_name"></div>
|
<input type="text" name="first_name" required id="id_first_name"></div>
|
||||||
"""
|
"""
|
||||||
self.assertHTMLEqual(html, expected)
|
self.assertHTMLEqual(html, expected)
|
||||||
get_default_renderer.cache_clear()
|
|
||||||
|
|
||||||
@override_settings(FORM_RENDERER="forms_tests.tests.test_forms.CustomRenderer")
|
@override_settings(FORM_RENDERER="forms_tests.tests.test_forms.CustomRenderer")
|
||||||
def test_custom_renderer_field_template_name(self):
|
def test_custom_renderer_field_template_name(self):
|
||||||
class Person(Form):
|
class Person(Form):
|
||||||
first_name = CharField()
|
first_name = CharField()
|
||||||
|
|
||||||
get_default_renderer.cache_clear()
|
|
||||||
t = Template("{{ form.first_name.as_field_group }}")
|
t = Template("{{ form.first_name.as_field_group }}")
|
||||||
html = t.render(Context({"form": Person()}))
|
html = t.render(Context({"form": Person()}))
|
||||||
expected = """
|
expected = """
|
||||||
@ -5169,7 +5166,6 @@ class OverrideTests(SimpleTestCase):
|
|||||||
<input type="text" name="first_name" required id="id_first_name">
|
<input type="text" name="first_name" required id="id_first_name">
|
||||||
"""
|
"""
|
||||||
self.assertHTMLEqual(html, expected)
|
self.assertHTMLEqual(html, expected)
|
||||||
get_default_renderer.cache_clear()
|
|
||||||
|
|
||||||
def test_per_form_template_name(self):
|
def test_per_form_template_name(self):
|
||||||
class Person(Form):
|
class Person(Form):
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.forms.renderers import get_default_renderer
|
|
||||||
from django.template import autoreload
|
from django.template import autoreload
|
||||||
from django.test import SimpleTestCase, override_settings
|
from django.test import SimpleTestCase, override_settings
|
||||||
from django.test.utils import require_jinja2
|
from django.test.utils import require_jinja2
|
||||||
@ -74,8 +73,6 @@ class TemplateReloadTests(SimpleTestCase):
|
|||||||
def test_form_template_reset_template_change_no_djangotemplates(
|
def test_form_template_reset_template_change_no_djangotemplates(
|
||||||
self, mock_loader_reset
|
self, mock_loader_reset
|
||||||
):
|
):
|
||||||
self.addCleanup(get_default_renderer.cache_clear)
|
|
||||||
get_default_renderer.cache_clear()
|
|
||||||
template_path = Path(__file__).parent / "templates" / "index.html"
|
template_path = Path(__file__).parent / "templates" / "index.html"
|
||||||
self.assertIs(autoreload.template_changed(None, template_path), True)
|
self.assertIs(autoreload.template_changed(None, template_path), True)
|
||||||
mock_loader_reset.assert_not_called()
|
mock_loader_reset.assert_not_called()
|
||||||
|
Loading…
Reference in New Issue
Block a user