Further removal of static admin validation that can fail erroneously

This commit is contained in:
Luke Plant 2013-05-09 15:11:02 +01:00
parent 1906cb9360
commit 1e37cb37ce
3 changed files with 0 additions and 40 deletions

View File

@ -246,7 +246,6 @@ def validate_fields_spec(cls, model, opts, flds, label):
# readonly_fields will handle the validation of such
# things.
continue
check_formfield(cls, model, opts, label, field)
try:
f = opts.get_field(field)
except models.FieldDoesNotExist:
@ -302,14 +301,6 @@ def validate_base(cls, model):
# exclude
if cls.exclude: # default value is None
check_isseq(cls, 'exclude', cls.exclude)
for field in cls.exclude:
check_formfield(cls, model, opts, 'exclude', field)
try:
f = opts.get_field(field)
except models.FieldDoesNotExist:
# If we can't find a field on the model that matches,
# it could be an extra field on the form.
continue
if len(cls.exclude) > len(set(cls.exclude)):
raise ImproperlyConfigured('There are duplicate field(s) in %s.exclude' % cls.__name__)
@ -380,14 +371,6 @@ def get_field(cls, model, opts, label, field):
raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is missing from model '%s.%s'."
% (cls.__name__, label, field, model._meta.app_label, model.__name__))
def check_formfield(cls, model, opts, label, field):
if getattr(cls.form, 'base_fields', None):
try:
cls.form.base_fields[field]
except KeyError:
raise ImproperlyConfigured("'%s.%s' refers to field '%s' that "
"is missing from the form." % (cls.__name__, label, field))
def fetch_attr(cls, model, opts, label, field):
try:
return opts.get_field(field)

View File

@ -269,8 +269,6 @@ class ValidationTestCase(TestCase):
"""
class SongForm(forms.ModelForm):
extra_data = forms.CharField()
class Meta:
model = Song
class FieldsOnFormOnlyAdmin(admin.ModelAdmin):
form = SongForm

View File

@ -682,27 +682,6 @@ class ValidationTests(unittest.TestCase):
validate(BandAdmin, Band)
class AdminBandForm(forms.ModelForm):
class Meta:
model = Band
class BandAdmin(ModelAdmin):
form = AdminBandForm
fieldsets = (
('Band', {
'fields': ('non_existent_field',)
}),
)
six.assertRaisesRegex(self,
ImproperlyConfigured,
"'BandAdmin.fieldsets\[0]\[1\]\['fields'\]' refers to field 'non_existent_field' that is missing from the form.",
validate,
BandAdmin,
Band,
)
class AdminBandForm(forms.ModelForm):
delete = forms.BooleanField()