Skip to content
This repository
Browse code

Merge pull request #293 from g1itch/master

Django 1.7 autodiscover support
  • Loading branch information...
commit 536a8162eff11b433dae6095e0d0dd658f1850b8 2 parents 8a5408e + 3a1bb89
James Pic jpic authored

Showing 1 changed file with 9 additions and 2 deletions. Show diff stats Hide diff stats

  1. +9 2 autocomplete_light/registry.py
11 autocomplete_light/registry.py
@@ -178,12 +178,19 @@ def __getitem__(self, name):
178 178 def _autodiscover(registry):
179 179 """See documentation for autodiscover (without the underscore)"""
180 180 import copy
  181 + from django import get_version
181 182 from django.conf import settings
182 183 from django.utils.importlib import import_module
183 184 from django.utils.module_loading import module_has_submodule
184 185
185   - for app in settings.INSTALLED_APPS:
186   - mod = import_module(app)
  186 + if get_version() >= '1.7':
  187 + from django.apps import apps
  188 + apps = ((app.module, app.module.__name__)
  189 + for app in apps.app_configs.values())
  190 + else:
  191 + apps = ((import_module(app), app) for app in settings.INSTALLED_APPS)
  192 +
  193 + for mod, app in apps:
187 194 # Attempt to import the app's admin module.
188 195 try:
189 196 before_import_registry = copy.copy(registry)

0 comments on commit 536a816

Please sign in to comment.
Something went wrong with that request. Please try again.