diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2022-08-02 09:34:18 +0200 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2022-08-02 10:31:04 +0200 |
| commit | 8aab03ab5550d8da9268eb384bfc7092dd4fab0a (patch) | |
| tree | b65d4f8af0b51903df73d0b8fe9f8f639ced410d | |
| parent | bdff4d5b3abf5ed84aa129df50409678e0926d11 (diff) | |
[4.1.x] Fixed #33876, Refs #32229 -- Made management forms render with div.html template.
Thanks to Claude Paroz for the report.
Backport of 89e695a69b16b8c0e720169b3ca4852cfd0c485f from main
| -rw-r--r-- | django/forms/formsets.py | 2 | ||||
| -rw-r--r-- | tests/forms_tests/tests/test_formsets.py | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 3adbc6979a..57676428ff 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -32,6 +32,8 @@ class ManagementForm(Form): as well. """ + template_name = "django/forms/div.html" # RemovedInDjango50Warning. + TOTAL_FORMS = IntegerField(widget=HiddenInput) INITIAL_FORMS = IntegerField(widget=HiddenInput) # MIN_NUM_FORM_COUNT and MAX_NUM_FORM_COUNT are output with the rest of the diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py index 96a2189d70..c36a79d4e0 100644 --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -1910,3 +1910,14 @@ class DeprecationTests(SimpleTestCase): ChoiceFormSet = formset_factory(Choice) formset = ChoiceFormSet() str(formset) + + def test_no_management_form_warning(self): + """ + Management forms are already rendered with the new div template. + """ + with isolate_lru_cache(get_default_renderer), self.settings( + FORM_RENDERER="django.forms.renderers.DjangoTemplates" + ): + ChoiceFormSet = formset_factory(Choice, formset=BaseFormSet) + formset = ChoiceFormSet() + str(formset.management_form) |
