1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

Fixed #5196 -- Merged over changes to validation.py that didn't get merged correctly in [5918].

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5921 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2007-08-18 01:19:25 +00:00
parent fcec755f01
commit 28e350301f

View File

@ -48,8 +48,6 @@ def get_validation_errors(outfile, app=None):
from PIL import Image from PIL import Image
except ImportError: except ImportError:
e.add(opts, '"%s": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name) e.add(opts, '"%s": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name)
if f.prepopulate_from is not None and type(f.prepopulate_from) not in (list, tuple):
e.add(opts, '"%s": prepopulate_from should be a list or tuple.' % f.name)
if f.choices: if f.choices:
if not hasattr(f.choices, '__iter__'): if not hasattr(f.choices, '__iter__'):
e.add(opts, '"%s": "choices" should be iterable (e.g., a tuple or list).' % f.name) e.add(opts, '"%s": "choices" should be iterable (e.g., a tuple or list).' % f.name)
@ -135,9 +133,14 @@ def get_validation_errors(outfile, app=None):
# Check admin attribute. # Check admin attribute.
if opts.admin is not None: if opts.admin is not None:
if not isinstance(opts.admin, models.AdminOptions): # prepopulated_fields
e.add(opts, '"admin" attribute, if given, must be set to a models.AdminOptions() instance.') if not isinstance(opts.admin.prepopulated_fields, dict):
e.add(opts, '"%s": prepopulated_fields should be a dictionary.' % f.name)
else: else:
for field_name, field_list in opts.admin.prepopulated_fields.items():
if not isinstance(field_list, (list, tuple)):
e.add(opts, '"%s": prepopulated_fields "%s" value should be a list or tuple.' % (f.name, field_name))
# list_display # list_display
if not isinstance(opts.admin.list_display, (list, tuple)): if not isinstance(opts.admin.list_display, (list, tuple)):
e.add(opts, '"admin.list_display", if given, must be set to a list or tuple.') e.add(opts, '"admin.list_display", if given, must be set to a list or tuple.')