Ticket #8299: form-attribute-doc-fix-00.diff

File form-attribute-doc-fix-00.diff, 1.2 KB (added by jarrow, 7 years ago)
  • docs/admin.txt

     
    7272``form``
    7373~~~~~~~~
    7474
    75 The default ``forms.ModelForm`` class used to generate the form on the
    76 add/change pages for models. You can easily change this to your own
    77 ``ModelForm`` to override the default form behavior of the add/change pages.
     75By default a subclass of ``forms.ModelForm`` is automatically generated for
     76your model. It is used to create the forms on the add/change pages. You can
     77easily change this subclass to your own ``ModelForm`` to override the default
     78form behavior of the add/change pages.
     79
     80For an example see the section `Adding custom validation to the admin`_.
    7881
    7982``fieldsets``
    8083~~~~~~~~~~~~~
     
    589592needed. Now within your form you can add your own custom validation for
    590593any field::
    591594   
    592     class MyArticleAdminForm(forms.ModelForm):
     595    class MyArticleAdminForm(forms.ModelForm):
     596        class Meta:
     597            model = MyModel
    593598        def clean_name(self):
    594599            # do something that validates your data
    595600            return self.cleaned_data["name"]
Back to Top