diff --git a/django/forms/models.py b/django/forms/models.py
index 56e7f2a..633b26c 100644
|
a
|
b
|
class BaseModelForm(BaseForm):
|
| 220 | 220 | except FieldDoesNotExist: |
| 221 | 221 | # This is an extra field that's not on the ModelForm, ignore it |
| 222 | 222 | continue |
| 223 | | # MySQL can't handle ... WHERE pk IS NULL, so make sure we don't |
| | 223 | # MySQL can't handle ... WHERE pk IS NULL, so make sure we |
| 224 | 224 | # don't generate queries of that form. |
| 225 | 225 | is_null_pk = f.primary_key and self.cleaned_data[name] is None |
| 226 | 226 | if name in self.cleaned_data and f.unique and not is_null_pk: |
| … |
… |
class BaseModelForm(BaseForm):
|
| 244 | 244 | if self.instance.pk is not None: |
| 245 | 245 | qs = qs.exclude(pk=self.instance.pk) |
| 246 | 246 | |
| 247 | | # This cute trick with extra/values is the most efficiant way to |
| | 247 | # This cute trick with extra/values is the most efficient way to |
| 248 | 248 | # tell if a particular query returns any results. |
| 249 | 249 | if qs.extra(select={'a': 1}).values('a').order_by(): |
| 250 | 250 | model_name = capfirst(self.instance._meta.verbose_name) |
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 80857ae..a56558a 100644
|
a
|
b
|
parameter when declaring the form field::
|
| 337 | 337 | Overriding the clean() method |
| 338 | 338 | ----------------------------- |
| 339 | 339 | |
| 340 | | You can overide the ``clean()`` method on a model form to provide additional |
| 341 | | validation in the same way you can on a normal form. However, by default the |
| | 340 | You can override the ``clean()`` method on a model form to provide additional |
| | 341 | validation in the same way you can on a normal form. However, by default the |
| 342 | 342 | ``clean()`` method validates the uniqueness of fields that are marked as unique |
| 343 | | on the model, and those marked as unque_together, if you would like to overide |
| 344 | | the ``clean()`` method and maintain the default validation you must call the |
| | 343 | or unique_together on the model. Therefore, if you would like to override |
| | 344 | the ``clean()`` method and maintain the default validation, you must call the |
| 345 | 345 | parent class's ``clean()`` method. |
| 346 | 346 | |
| 347 | 347 | Form inheritance |