Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

newforms-admin: Fixed #7772 -- Moved the validation check for when bo…

…th fields and fieldsets are specified on a ModelAdmin to django/contrib/admin/validation.py. Thanks Julien Phalip for catching this.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7932 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 83afd39b1aa0e4235a8490ebc7219f97c35a0106 1 parent 5317864
@brosner brosner authored
View
1  AUTHORS
@@ -297,6 +297,7 @@ answer newbie questions, and generally made Django that much better:
peter@mymart.com
pgross@thoughtworks.com
phaedo <http://phaedo.cx/>
+ Julien Phalip <http://www.julienphalip.com>
phil@produxion.net
phil.h.smith@gmail.com
Gustavo Picon
View
6 django/contrib/admin/options.py
@@ -143,12 +143,6 @@ class BaseModelAdmin(object):
radio_fields = {}
prepopulated_fields = {}
- def __init__(self):
- # TODO: This should really go in django.core.validation, but validation
- # doesn't work on ModelAdmin classes yet.
- if self.fieldsets and self.fields:
- raise ImproperlyConfigured('Both fieldsets and fields is specified for %s.' % self.model)
-
def formfield_for_dbfield(self, db_field, **kwargs):
"""
Hook for specifying the form Field instance for a given database Field
View
2  django/contrib/admin/validation.py
@@ -160,6 +160,8 @@ def _check_field_existsw(label, field):
_check_istuplew('fields', cls.fields)
for field in cls.fields:
_check_field_existsw('fields', field)
+ if cls.fieldsets:
+ raise ImproperlyConfigured('Both fieldsets and fields are specified in %s.' % cls.__name__)
# fieldsets
if cls.fieldsets: # default value is None
View
8 tests/regressiontests/modeladmin/models.py
@@ -338,6 +338,14 @@ class and an AdminSite instance, so let's just go ahead and do that manually
... fieldsets = (("General", {"fields": ("name",)}),)
>>> validate(ValidationTestModelAdmin, ValidationTestModel)
+>>> class ValidationTestModelAdmin(ModelAdmin):
+... fieldsets = (("General", {"fields": ("name",)}),)
+... fields = ["name",]
+>>> validate(ValidationTestModelAdmin, ValidationTestModel)
+Traceback (most recent call last):
+...
+ImproperlyConfigured: Both fieldsets and fields are specified in ValidationTestModelAdmin.
+
# form
>>> class FakeForm(object):
Please sign in to comment.
Something went wrong with that request. Please try again.