mirror of
https://github.com/django/django.git
synced 2025-07-03 17:29:12 +00:00
newforms-admin: Fixed #7772 -- Moved the validation check for when both 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
This commit is contained in:
parent
5317864e5f
commit
83afd39b1a
1
AUTHORS
1
AUTHORS
@ -297,6 +297,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
peter@mymart.com
|
peter@mymart.com
|
||||||
pgross@thoughtworks.com
|
pgross@thoughtworks.com
|
||||||
phaedo <http://phaedo.cx/>
|
phaedo <http://phaedo.cx/>
|
||||||
|
Julien Phalip <http://www.julienphalip.com>
|
||||||
phil@produxion.net
|
phil@produxion.net
|
||||||
phil.h.smith@gmail.com
|
phil.h.smith@gmail.com
|
||||||
Gustavo Picon
|
Gustavo Picon
|
||||||
|
@ -143,12 +143,6 @@ class BaseModelAdmin(object):
|
|||||||
radio_fields = {}
|
radio_fields = {}
|
||||||
prepopulated_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):
|
def formfield_for_dbfield(self, db_field, **kwargs):
|
||||||
"""
|
"""
|
||||||
Hook for specifying the form Field instance for a given database Field
|
Hook for specifying the form Field instance for a given database Field
|
||||||
|
@ -160,6 +160,8 @@ def _validate_base(cls, model):
|
|||||||
_check_istuplew('fields', cls.fields)
|
_check_istuplew('fields', cls.fields)
|
||||||
for field in cls.fields:
|
for field in cls.fields:
|
||||||
_check_field_existsw('fields', field)
|
_check_field_existsw('fields', field)
|
||||||
|
if cls.fieldsets:
|
||||||
|
raise ImproperlyConfigured('Both fieldsets and fields are specified in %s.' % cls.__name__)
|
||||||
|
|
||||||
# fieldsets
|
# fieldsets
|
||||||
if cls.fieldsets: # default value is None
|
if cls.fieldsets: # default value is None
|
||||||
|
@ -338,6 +338,14 @@ ImproperlyConfigured: `ValidationTestModelAdmin.fieldsets[0][1]['fields']` refer
|
|||||||
... fieldsets = (("General", {"fields": ("name",)}),)
|
... fieldsets = (("General", {"fields": ("name",)}),)
|
||||||
>>> validate(ValidationTestModelAdmin, ValidationTestModel)
|
>>> 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
|
# form
|
||||||
|
|
||||||
>>> class FakeForm(object):
|
>>> class FakeForm(object):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user