Replaces #301 autodiscover works with AppConfig

This commit is contained in:
Venelin Stoykov 2017-02-22 14:21:09 +02:00
parent 3546c39178
commit 755193699b

View file

@ -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