diff --git a/django/forms/models.py b/django/forms/models.py
index 0039516..d914f89 100644
|
a
|
b
|
class BaseModelForm(BaseForm):
|
| 276 | 276 | # adding these values to the model after form validation. |
| 277 | 277 | if field not in self.fields: |
| 278 | 278 | exclude.append(f.name) |
| | 279 | |
| | 280 | # if some fields were excluded, don't run their validation |
| | 281 | # this is needed on top of previous line to catch fields added onto |
| | 282 | # the form with same name as some model field |
| | 283 | elif self._meta.fields and field not in self._meta.fields: |
| | 284 | exclude.append(f.name) |
| 279 | 285 | # Exclude fields that failed form validation. There's no need for |
| 280 | 286 | # the model fields to validate them as well. |
| 281 | 287 | elif field in self._errors.keys(): |
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index b8b826a..12a39b5 100644
|
a
|
b
|
words, most of these tests should be rewritten.
|
| 9 | 9 | |
| 10 | 10 | import os |
| 11 | 11 | import tempfile |
| | 12 | from unittest import TestCase |
| 12 | 13 | |
| 13 | 14 | from django.db import models |
| 14 | 15 | from django.core.files.storage import FileSystemStorage |
| | 16 | from django import forms |
| | 17 | from django.forms.models import ModelForm |
| 15 | 18 | |
| 16 | 19 | temp_storage_dir = tempfile.mkdtemp() |
| 17 | 20 | temp_storage = FileSystemStorage(temp_storage_dir) |
| … |
… |
class BigInt(models.Model):
|
| 205 | 208 | def __unicode__(self): |
| 206 | 209 | return unicode(self.biggie) |
| 207 | 210 | |
| | 211 | class IncompleteCategoryForm(ModelForm): |
| | 212 | url = forms.CharField(required=False) |
| | 213 | |
| | 214 | class Meta: |
| | 215 | fields = ('name', 'slug') |
| | 216 | model = Category |
| | 217 | |
| | 218 | class TestCase(TestCase): |
| | 219 | def test_category_doesnt_validate_url_when_not_on_modelform(self): |
| | 220 | form = IncompleteCategoryForm(data={'name': 'some name', 'slug': 'some-slug'}) |
| | 221 | assert form.is_valid() |
| | 222 | |
| 208 | 223 | __test__ = {'API_TESTS': """ |
| 209 | 224 | >>> from django import forms |
| 210 | 225 | >>> from django.forms.models import ModelForm, model_to_dict |