diff --git a/imagekit/management/commands/ikflush.py b/imagekit/management/commands/ikflush.py index c03440f..978caff 100644 --- a/imagekit/management/commands/ikflush.py +++ b/imagekit/management/commands/ikflush.py @@ -20,19 +20,17 @@ def flush_cache(apps, options): """ apps = [a.strip(',') for a in apps] if apps: - print 'Flushing cache for %s...' % ', '.join(apps) + for app_label in apps: + app = cache.get_app(app_label) + models = [m for m in cache.get_models(app) if issubclass(m, ImageModel)] + for model in models: + print 'Flushing cache for "%s.%s"' % (app_label, model.__name__) + for obj in model.objects.all(): + for spec in model._ik.specs: + prop = getattr(obj, spec.name(), None) + if prop is not None: + prop._delete() + if spec.pre_cache: + prop._create() else: - print 'Flushing caches...' - - for app_label in apps: - app = cache.get_app(app_label) - models = [m for m in cache.get_models(app) if issubclass(m, ImageModel)] - - for model in models: - for obj in model.objects.all(): - for spec in model._ik.specs: - prop = getattr(obj, spec.name(), None) - if prop is not None: - prop._delete() - if spec.pre_cache: - prop._create() + print 'Please specify on or more app names'