mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-05-16 08:43:09 +00:00
* 'new_api' of https://github.com/matthewwithanm/django-imagekit: (63 commits) fixing typo ImageSpecFile is a proper File Typo fix A list of ImageSpec names are now stored on the model. AdminThumbnailView is now AdminThumbnail Docs typo fix Adds explicit import of resize module to processors fixing bad import in docs adding name to AUTHORS adding test for new api Moved Crop and Fit to resize module. More docs edits. Typo fix. Installation instructions. Embracing duck typing. Documentation! Fix bug Bound fields are now cached on the model instance. Transpose processor now supports auto EXIF orientation. Fix filename formatting. ... Conflicts: AUTHORS README.rst docs/Makefile docs/conf.py docs/index.rst imagekit/__init__.py imagekit/defaults.py imagekit/management/commands/ikflush.py imagekit/models.py imagekit/options.py imagekit/processors.py imagekit/specs.py tests/core/tests.py
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""Flushes the cached ImageKit images.
|
|
|
|
"""
|
|
|
|
from django.db.models.loading import cache
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
from optparse import make_option
|
|
from imagekit.utils import get_spec_files
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = ('Clears all ImageKit cached files.')
|
|
args = '[apps]'
|
|
requires_model_validation = True
|
|
can_import_settings = True
|
|
|
|
def handle(self, *args, **options):
|
|
return flush_cache(args, options)
|
|
|
|
|
|
def flush_cache(apps, options):
|
|
apps = [a.strip(',') for a in apps]
|
|
if apps:
|
|
for app_label in apps:
|
|
app = cache.get_app(app_label)
|
|
for model in [m for m in cache.get_models(app)]:
|
|
print 'Flushing cache for "%s.%s"' % (app_label, model.__name__)
|
|
for obj in model.objects.order_by('-pk'):
|
|
for spec_file in get_spec_files(obj):
|
|
if spec_file is not None:
|
|
spec_file.delete(save=False)
|
|
if spec_file.field.pre_cache:
|
|
spec_file._create()
|
|
else:
|
|
print 'Please specify one or more app names'
|