Skip to content

Commit

Permalink
Fixed #8299 -- Clarified the ModelAdmin.form option. Also added an in…
Browse files Browse the repository at this point in the history
…ner Meta class to the ModelForm example in adding custom validation to the admin. Thanks jarrow for the report and initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8395 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
brosner committed Aug 15, 2008
1 parent 6a71c76 commit 8edb4f9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions docs/admin.txt
Expand Up @@ -72,9 +72,14 @@ Example::
``form``
~~~~~~~~

The default ``forms.ModelForm`` class used to generate the form on the
add/change pages for models. You can easily change this to your own
``ModelForm`` to override the default form behavior of the add/change pages.
By default a ``ModelForm`` is dynamically created for your model. It is used
to create the form presented on both the add/change pages. You can easily
provide your own ``ModelForm`` to override any default form behavior on the
add/change pages.

For an example see the section `Adding custom validation to the admin`_.

.. _Adding custom validation to the admin: #adding-custom-validation-to-the-admin

``fieldsets``
~~~~~~~~~~~~~
Expand Down Expand Up @@ -617,6 +622,9 @@ needed. Now within your form you can add your own custom validation for
any field::

class MyArticleAdminForm(forms.ModelForm):
class Meta:
model = Article

def clean_name(self):
# do something that validates your data
return self.cleaned_data["name"]
Expand Down

0 comments on commit 8edb4f9

Please sign in to comment.