1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fix UnboundLocalError than could occur during ModelAdmin validation.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16262 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey
2011-05-22 15:51:22 +00:00
parent d95355b6db
commit 909e002808
2 changed files with 19 additions and 3 deletions

View File

@@ -256,3 +256,19 @@ class ValidationTestCase(TestCase):
fields = ['title', 'extra_data']
validate(FieldsOnFormOnlyAdmin, Song)
def test_non_model_first_field(self):
"""
Regression for ensuring ModelAdmin.field can handle first elem being a
non-model field (test fix for UnboundLocalError introduced with r16225).
"""
class SongForm(forms.ModelForm):
extra_data = forms.CharField()
class Meta:
model = Song
class FieldsOnFormOnlyAdmin(admin.ModelAdmin):
form = SongForm
fields = ['extra_data', 'title']
validate(FieldsOnFormOnlyAdmin, Song)