Fixed #33876, Refs #32229 -- Made management forms render with div.html template.

Thanks to Claude Paroz for the report.
This commit is contained in:
Carlton Gibson 2022-08-02 09:34:18 +02:00 committed by Carlton Gibson
parent 44c24bf028
commit 89e695a69b
2 changed files with 13 additions and 0 deletions

View File

@ -32,6 +32,8 @@ class ManagementForm(Form):
as well. as well.
""" """
template_name = "django/forms/div.html" # RemovedInDjango50Warning.
TOTAL_FORMS = IntegerField(widget=HiddenInput) TOTAL_FORMS = IntegerField(widget=HiddenInput)
INITIAL_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 # MIN_NUM_FORM_COUNT and MAX_NUM_FORM_COUNT are output with the rest of the

View File

@ -1910,3 +1910,14 @@ class DeprecationTests(SimpleTestCase):
ChoiceFormSet = formset_factory(Choice) ChoiceFormSet = formset_factory(Choice)
formset = ChoiceFormSet() formset = ChoiceFormSet()
str(formset) 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)