mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-04-25 15:34:42 +00:00
Merge branch 'release/3.2.6'
* release/3.2.6: Bump the version to 3.2.6. Updated importlib import to fix DeprecationWarning (for django 1.8) Add note about usage of optimistic strategy with async backend Fix typo
This commit is contained in:
commit
b398c2cee4
3 changed files with 26 additions and 5 deletions
|
|
@ -71,7 +71,7 @@ The default works like this:
|
|||
* If not, caches that information for 5 seconds
|
||||
* If it does, caches that information in the ``IMAGEKIT_CACHE_BACKEND``
|
||||
|
||||
If file doesn't exsit, generates it immediately and synchronously
|
||||
If file doesn't exist, generates it immediately and synchronously
|
||||
|
||||
|
||||
That pretty much covers the architecture of the caching layer, and its default
|
||||
|
|
@ -132,7 +132,7 @@ As mentioned above, image generation is normally done synchronously. through
|
|||
the default cache file backend. However, you can also take advantage of
|
||||
deferred generation. In order to do this, you'll need to do two things:
|
||||
|
||||
1) install `django-celery`__
|
||||
1) install `celery`__ (or `django-celery`__ if you are bound to Celery<3.1)
|
||||
2) tell ImageKit to use the async cachefile backend.
|
||||
To do this for all specs, set the ``IMAGEKIT_DEFAULT_CACHEFILE_BACKEND`` in
|
||||
your settings
|
||||
|
|
@ -164,8 +164,23 @@ Or, in Python:
|
|||
else:
|
||||
url = '/path/to/placeholder.jpg'
|
||||
|
||||
.. note::
|
||||
|
||||
If you are using an "async" backend in combination with the "optimistic"
|
||||
cache file strategy (see `Removing Safeguards`_ below), checking for
|
||||
thruthiness as described above will not work. The "optimistic" backend is
|
||||
very optimistic so to say, and removes the check. Create and use the
|
||||
following strategy to a) have images only created on save, and b) retain
|
||||
the ability to check whether the images have already been created::
|
||||
|
||||
class ImagekitOnSaveStrategy(object):
|
||||
def on_source_saved(self, file):
|
||||
file.generate()
|
||||
|
||||
|
||||
|
||||
__ https://pypi.python.org/pypi/django-celery
|
||||
__ http://www.celeryproject.org
|
||||
|
||||
|
||||
Removing Safeguards
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
__title__ = 'django-imagekit'
|
||||
__author__ = 'Matthew Tretter, Eric Eldredge, Bryan Veloso, Greg Newman, Chris Drackett, Justin Driscoll'
|
||||
__version__ = '3.2.5'
|
||||
__version__ = '3.2.6'
|
||||
__license__ = 'BSD'
|
||||
__all__ = ['__title__', '__author__', '__version__', '__license__']
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ from hashlib import md5
|
|||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.files import File
|
||||
from django.utils.importlib import import_module
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
from django.utils.importlib import import_module
|
||||
from pilkit.utils import *
|
||||
from .lib import NullHandler, force_bytes
|
||||
|
||||
|
|
@ -70,7 +73,10 @@ def autodiscover():
|
|||
return
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.importlib import import_module
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.module_loading import module_has_submodule
|
||||
|
||||
_autodiscovered = True
|
||||
|
|
|
|||
Loading…
Reference in a new issue