diff options
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/formsets.txt | 6 | ||||
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index f1419b6a92..a41c4a0196 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -533,7 +533,7 @@ default fields/attributes of the order and deletion fields:: >>> from myapp.forms import ArticleForm >>> class BaseArticleFormSet(BaseFormSet): ... def add_fields(self, form, index): - ... super(BaseArticleFormSet, self).add_fields(form, index) + ... super().add_fields(form, index) ... form.fields["my_field"] = forms.CharField() >>> ArticleFormSet = formset_factory(ArticleForm, formset=BaseArticleFormSet) @@ -559,7 +559,7 @@ You can pass this parameter when instantiating the formset:: >>> class MyArticleForm(ArticleForm): ... def __init__(self, *args, **kwargs): ... self.user = kwargs.pop('user') - ... super(MyArticleForm, self).__init__(*args, **kwargs) + ... super().__init__(*args, **kwargs) >>> ArticleFormSet = formset_factory(MyArticleForm) >>> formset = ArticleFormSet(form_kwargs={'user': request.user}) @@ -574,7 +574,7 @@ argument - the index of the form in the formset. The index is ``None`` for the >>> class BaseArticleFormSet(BaseFormSet): ... def get_form_kwargs(self, index): - ... kwargs = super(BaseArticleFormSet, self).get_form_kwargs(index) + ... kwargs = super().get_form_kwargs(index) ... kwargs['custom_kwarg'] = index ... return kwargs diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index a3a8179169..e638009c8c 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -797,7 +797,7 @@ Alternatively, you can create a subclass that sets ``self.queryset`` in class BaseAuthorFormSet(BaseModelFormSet): def __init__(self, *args, **kwargs): - super(BaseAuthorFormSet, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.queryset = Author.objects.filter(name__startswith='O') Then, pass your ``BaseAuthorFormSet`` class to the factory function:: @@ -1002,7 +1002,7 @@ class's ``clean`` method:: class MyModelFormSet(BaseModelFormSet): def clean(self): - super(MyModelFormSet, self).clean() + super().clean() # example custom validation across forms in the formset for form in self.forms: # your custom formset validation @@ -1018,7 +1018,7 @@ to modify a value in ``ModelFormSet.clean()`` you must modify class MyModelFormSet(BaseModelFormSet): def clean(self): - super(MyModelFormSet, self).clean() + super().clean() for form in self.forms: name = form.cleaned_data['name'].upper() @@ -1164,7 +1164,7 @@ For example, if you want to override ``clean()``:: class CustomInlineFormSet(BaseInlineFormSet): def clean(self): - super(CustomInlineFormSet, self).clean() + super().clean() # example custom validation across forms in the formset for form in self.forms: # your custom formset validation |
