mirror of https://github.com/django/django.git
Improved model validator so that it validates admin.list_display values
git-svn-id: http://code.djangoproject.com/svn/django/trunk@650 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1d65ba62db
commit
7dfb86724d
|
@ -537,8 +537,20 @@ def get_validation_errors(outfile):
|
|||
e.add(opts, '"%s" field: "choices" should be a sequence of two-tuples.' % f.name)
|
||||
|
||||
# Check admin attribute.
|
||||
if opts.admin is not None and not isinstance(opts.admin, meta.Admin):
|
||||
e.add(opts, '"admin" attribute, if given, must be set to a meta.Admin() instance.')
|
||||
if opts.admin is not None:
|
||||
if not isinstance(opts.admin, meta.Admin):
|
||||
e.add(opts, '"admin" attribute, if given, must be set to a meta.Admin() instance.')
|
||||
else:
|
||||
for fn in opts.admin.list_display:
|
||||
try:
|
||||
f = opts.get_field(fn)
|
||||
except meta.FieldDoesNotExist:
|
||||
klass = opts.get_model_module().Klass
|
||||
if not hasattr(klass, fn) or not callable(getattr(klass, fn)):
|
||||
e.add(opts, '"admin.list_display" refers to %r, which isn\'t a field or method.' % fn)
|
||||
else:
|
||||
if isinstance(f, meta.ManyToManyField):
|
||||
e.add(opts, '"admin.list_display" doesn\'t support ManyToManyFields (%r).' % fn)
|
||||
|
||||
# Check ordering attribute.
|
||||
if opts.ordering:
|
||||
|
|
Loading…
Reference in New Issue