diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-03-18 16:55:59 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-03-18 16:55:59 +0000 |
| commit | c485e236bd7e5ea40c64b2fe54d85dbb15b2fd39 (patch) | |
| tree | fc5e86abf39b69181b2084f5c39038f1811b6b44 /django/contrib/admin | |
| parent | ee2f04d79e5bca55637b9bb3301618738a4e342a (diff) | |
Fixed #8193: all dynamic imports in Django are now done correctly. I know this because Brett Cannon borrowed the time machine and brought Python 2.7's '`importlib` back for inclusion in Django. Thanks for the patch-from-the-future, Brett!
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10088 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib/admin')
| -rw-r--r-- | django/contrib/admin/__init__.py | 5 | ||||
| -rw-r--r-- | django/contrib/admin/views/template.py | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/django/contrib/admin/__init__.py b/django/contrib/admin/__init__.py index bb856a1241..b2eeeebb1e 100644 --- a/django/contrib/admin/__init__.py +++ b/django/contrib/admin/__init__.py @@ -1,6 +1,7 @@ from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL from django.contrib.admin.options import StackedInline, TabularInline from django.contrib.admin.sites import AdminSite, site +from django.utils.importlib import import_module # A flag to tell us if autodiscover is running. autodiscover will set this to # True while running, and False when it finishes. @@ -36,7 +37,7 @@ def autodiscover(): # fails silently -- apps that do weird things with __path__ might # need to roll their own admin registration. try: - app_path = __import__(app, {}, {}, [app.split('.')[-1]]).__path__ + app_path = import_module(app).__path__ except AttributeError: continue @@ -51,6 +52,6 @@ def autodiscover(): # Step 3: import the app's admin file. If this has errors we want them # to bubble up. - __import__("%s.admin" % app) + import_module("%s.admin" % app) # autodiscover was successful, reset loading flag. LOADING = False diff --git a/django/contrib/admin/views/template.py b/django/contrib/admin/views/template.py index de9320bfc2..e1f64957c6 100644 --- a/django/contrib/admin/views/template.py +++ b/django/contrib/admin/views/template.py @@ -4,6 +4,7 @@ from django.template import loader from django.shortcuts import render_to_response from django.contrib.sites.models import Site from django.conf import settings +from django.utils.importlib import import_module from django.utils.translation import ugettext_lazy as _ @@ -15,7 +16,7 @@ def template_validator(request): # get a dict of {site_id : settings_module} for the validator settings_modules = {} for mod in settings.ADMIN_FOR: - settings_module = __import__(mod, {}, {}, ['']) + settings_module = import_module(mod) settings_modules[settings_module.SITE_ID] = settings_module site_list = Site.objects.in_bulk(settings_modules.keys()).values() if request.POST: |
