Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #12901. Exclude overridden form fields from model field validat…
…ion. Thanks, Honza Král. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12496 bcc190cf-cafb-0310-a4f2-bffc1f526a37
- Loading branch information
1 parent
9b8c44c
commit eb0751a
Showing
2 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
|