From 26c4356e015d7087ed9f5393421623224cb055b2 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sun, 25 Sep 2005 20:01:30 +0000 Subject: [PATCH] Improved model validator so that it checks for PIL if ImageFields are used git-svn-id: http://code.djangoproject.com/svn/django/trunk@685 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/django/core/management.py b/django/core/management.py index 9a970d3a75..6094430dae 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -524,6 +524,11 @@ def get_validation_errors(outfile): e.add(opts, '"%s" field: CharFields require a "maxlength" attribute.' % f.name) if isinstance(f, meta.FileField) and not f.upload_to: e.add(opts, '"%s" field: FileFields require an "upload_to" attribute.' % f.name) + if isinstance(f, meta.ImageField): + try: + from PIL import Image + except ImportError: + e.add(opts, '"%s" field: To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .') if f.prepopulate_from is not None and type(f.prepopulate_from) not in (list, tuple): e.add(opts, '"%s" field: prepopulate_from should be a list or tuple.' % f.name) if f.choices: