mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #8209: ModelForms now validate unique constraints. Alex Gaynor did much of this work, and Brian Rosner helped as well.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8805 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -338,6 +338,16 @@ parameter when declaring the form field::
|
||||
... class Meta:
|
||||
... model = Article
|
||||
|
||||
Overriding the clean() method
|
||||
-----------------------------
|
||||
|
||||
You can overide the ``clean()`` method on a model form to provide additional
|
||||
validation in the same way you can on a normal form. However, by default the
|
||||
``clean()`` method validates the uniqueness of fields that are marked as unique
|
||||
on the model, and those marked as unque_together, if you would like to overide
|
||||
the ``clean()`` method and maintain the default validation you must call the
|
||||
parent class's ``clean()`` method.
|
||||
|
||||
Form inheritance
|
||||
----------------
|
||||
|
||||
@@ -500,4 +510,4 @@ books of a specific author. Here is how you could accomplish this::
|
||||
>>> from django.forms.models import inlineformset_factory
|
||||
>>> BookFormSet = inlineformset_factory(Author, Book)
|
||||
>>> author = Author.objects.get(name=u'Orson Scott Card')
|
||||
>>> formset = BookFormSet(instance=author)
|
||||
>>> formset = BookFormSet(instance=author)
|
||||
|
||||
Reference in New Issue
Block a user