diff --git a/imagekit/utils.py b/imagekit/utils.py index 61caecb..27902c9 100644 --- a/imagekit/utils.py +++ b/imagekit/utils.py @@ -69,6 +69,30 @@ def autodiscover(): """ global _autodiscovered + if _autodiscovered: + return + + try: + from django.utils.module_loading import autodiscover_modules + except ImportError: + # Django<1.7 + _autodiscover_modules_fallback() + else: + autodiscover_modules('imagegenerators') + + +def _autodiscover_modules_fallback(): + """ + Auto-discover INSTALLED_APPS imagegenerators.py modules and fail silently + when not present. This forces an import on them to register any admin bits + they may want. + + Copied from django.contrib.admin + + Used for Django versions < 1.7 + """ + global _autodiscovered + if _autodiscovered: return