diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2010-02-22 23:06:09 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2010-02-22 23:06:09 +0000 |
| commit | eb0751a4c0b2d5e248ff3babc37a4764b102e25a (patch) | |
| tree | 284716c82996c54a8f74df73ab08251b3c748d63 /tests | |
| parent | 9b8c44c3ed60ab6d41af5fa9dad88d41d47dc45f (diff) | |
Fixed #12901. Exclude overridden form fields from model field validation. Thanks, Honza Král.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12496 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/model_forms/tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/modeltests/model_forms/tests.py b/tests/modeltests/model_forms/tests.py new file mode 100644 index 0000000000..49ea314bc6 --- /dev/null +++ b/tests/modeltests/model_forms/tests.py @@ -0,0 +1,21 @@ +from django.test import TestCase +from django import forms +from models import Category + + +class IncompleteCategoryForm(forms.ModelForm): + """ + A form that replaces the model's url field with a custom one. This should + prevent the model field's validation from being called. + """ + url = forms.CharField(required=False) + + class Meta: + fields = ('name', 'slug') + model = Category + +class ValidationTest(TestCase): + def test_validates_with_replaced_field(self): + form = IncompleteCategoryForm(data={'name': 'some name', 'slug': 'some-slug'}) + assert form.is_valid() + |
