diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-09-20 02:48:25 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-09-20 02:48:25 +0000 |
| commit | 7dfb86724dabcc64e2bb805f9992599a89d17a6e (patch) | |
| tree | 79533adfc36b82860d5e0b5f454a1ef47c9a1c15 /django/core/management.py | |
| parent | 1d65ba62dbfb9e6f13bccbf03bf9444c6c6d6481 (diff) | |
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
Diffstat (limited to 'django/core/management.py')
| -rw-r--r-- | django/core/management.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/django/core/management.py b/django/core/management.py index 21e3f7c78c..64f902b999 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -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: |
