diff options
| author | Adam Johnson <me@adamj.eu> | 2021-12-09 16:42:27 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-12-10 10:04:28 +0100 |
| commit | 702c314c57b4c5ea762fa71fe5856b8f586dcc65 (patch) | |
| tree | 4a242cdb6db4decca17e5dc33130046663a1e11f /django/forms/formsets.py | |
| parent | 0d2435328aaacdcfc5fae2baae21bfacf2244ee4 (diff) | |
Moved ManagementForm's fields to class attributes.
This helps introspection, and it follows the comment in
BaseForm.__init__() to avoid changing base_fields.
Thanks to Silvio Gutierrez and Baptiste Mispelon for investigating.
Diffstat (limited to 'django/forms/formsets.py')
| -rw-r--r-- | django/forms/formsets.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 383ad6f6af..aca518b4d2 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -30,15 +30,13 @@ class ManagementForm(Form): new forms via JavaScript, you should increment the count field of this form as well. """ - def __init__(self, *args, **kwargs): - self.base_fields[TOTAL_FORM_COUNT] = IntegerField(widget=HiddenInput) - self.base_fields[INITIAL_FORM_COUNT] = IntegerField(widget=HiddenInput) - # MIN_NUM_FORM_COUNT and MAX_NUM_FORM_COUNT are output with the rest of - # the management form, but only for the convenience of client-side - # code. The POST value of them returned from the client is not checked. - self.base_fields[MIN_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput) - self.base_fields[MAX_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput) - super().__init__(*args, **kwargs) + 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 + # management form, but only for the convenience of client-side code. The + # POST value of them returned from the client is not checked. + MIN_NUM_FORMS = IntegerField(required=False, widget=HiddenInput) + MAX_NUM_FORMS = IntegerField(required=False, widget=HiddenInput) def clean(self): cleaned_data = super().clean() |
