From d647678c2e674b4896ee4fe41678a72a82189f80 Mon Sep 17 00:00:00 2001 From: Sean Hayes Date: Wed, 14 Aug 2013 22:07:46 -0400 Subject: [PATCH] Added global boolean to prevent autodiscover() from being called more than once. --- imagekit/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/imagekit/utils.py b/imagekit/utils.py index 188a111..13bd843 100644 --- a/imagekit/utils.py +++ b/imagekit/utils.py @@ -13,6 +13,7 @@ from .lib import NullHandler bad_memcached_key_chars = re.compile(ur'[\u0000-\u001f\s]+') +_autodiscovered = False def get_nonabstract_descendants(model): """ Returns all non-abstract descendants of the model. """ @@ -62,11 +63,17 @@ def autodiscover(): Copied from django.contrib.admin """ + global _autodiscovered + + if _autodiscovered: + return from django.conf import settings from django.utils.importlib import import_module from django.utils.module_loading import module_has_submodule + _autodiscovered = True + for app in settings.INSTALLED_APPS: mod = import_module(app) # Attempt to import the app's admin module.