Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Further removal of static admin validation that can fail erroneously

  • Loading branch information...
commit 1e37cb37cec330a6b78925e2ef5589817428d09a 1 parent 1906cb9
@spookylukey spookylukey authored
View
17 django/contrib/admin/validation.py
@@ -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
2  tests/admin_validation/tests.py
@@ -269,8 +269,6 @@ def test_non_model_fields(self):
"""
class SongForm(forms.ModelForm):
extra_data = forms.CharField()
- class Meta:
- model = Song
class FieldsOnFormOnlyAdmin(admin.ModelAdmin):
form = SongForm
View
21 tests/modeladmin/tests.py
@@ -683,27 +683,6 @@ class BandAdmin(ModelAdmin):
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()
class Meta:
Please sign in to comment.
Something went wrong with that request. Please try again.