diff --git a/django/forms/models.py b/django/forms/models.py
index 56e7f2a..f4036e5 100644
a
|
b
|
class BaseModelForm(BaseForm):
|
210 | 210 | |
211 | 211 | def validate_unique(self): |
212 | 212 | from django.db.models.fields import FieldDoesNotExist |
213 | | unique_checks = list(self.instance._meta.unique_together[:]) |
| 213 | unique_checks = [check for check in self.instance._meta.unique_together[:] if len([x for x in check if x in self.fields.keys()]) == len(check)] |
214 | 214 | form_errors = [] |
215 | 215 | |
216 | 216 | # Make sure the unique checks apply to actual fields on the ModelForm |
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index dd6e25f..e3821de 100644
a
|
b
|
False
|
1192 | 1192 | >>> form._errors |
1193 | 1193 | {'__all__': [u'Price with this Price and Quantity already exists.']} |
1194 | 1194 | |
| 1195 | >>> class PriceForm(ModelForm): |
| 1196 | ... class Meta: |
| 1197 | ... model = Price |
| 1198 | ... exclude = ('quantity',) |
| 1199 | >>> form = PriceForm({'price': '6.00'}) |
| 1200 | >>> form.is_valid() |
| 1201 | True |
| 1202 | |
1195 | 1203 | # Choices on CharField and IntegerField |
1196 | 1204 | >>> class ArticleForm(ModelForm): |
1197 | 1205 | ... class Meta: |