mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Merge pull request #291 from danxshap/import_fix
Fix a Django 1.7 issue with importing INSTALLED_APPS modules
This commit is contained in:
commit
7f40d4fd4b
1 changed files with 14 additions and 9 deletions
|
|
@ -76,16 +76,21 @@ def autodiscover():
|
|||
_autodiscovered = True
|
||||
|
||||
for app in settings.INSTALLED_APPS:
|
||||
mod = import_module(app)
|
||||
# Attempt to import the app's admin module.
|
||||
# As of Django 1.7, settings.INSTALLED_APPS may contain classes instead of modules, hence the try/except
|
||||
# See here: https://docs.djangoproject.com/en/dev/releases/1.7/#introspecting-applications
|
||||
try:
|
||||
import_module('%s.imagegenerators' % app)
|
||||
except:
|
||||
# Decide whether to bubble up this error. If the app just
|
||||
# doesn't have an imagegenerators module, we can ignore the error
|
||||
# attempting to import it, otherwise we want it to bubble up.
|
||||
if module_has_submodule(mod, 'imagegenerators'):
|
||||
raise
|
||||
mod = import_module(app)
|
||||
# Attempt to import the app's admin module.
|
||||
try:
|
||||
import_module('%s.imagegenerators' % app)
|
||||
except:
|
||||
# Decide whether to bubble up this error. If the app just
|
||||
# doesn't have an imagegenerators module, we can ignore the error
|
||||
# attempting to import it, otherwise we want it to bubble up.
|
||||
if module_has_submodule(mod, 'imagegenerators'):
|
||||
raise
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def get_logger(logger_name='imagekit', add_null_handler=True):
|
||||
|
|
|
|||
Loading…
Reference in a new issue