Ticket #8245: Misleading-AlreadyRegistered-02.diff

File Misleading-AlreadyRegistered-02.diff, 1.3 KB (added by oyvind, 16 years ago)

this was what i meant :)

  • django/contrib/admin/__init__.py

    diff --git a/django/contrib/admin/__init__.py b/django/contrib/admin/__init__.py
    index 704dc58..8367501 100644
    a b from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL  
    22from django.contrib.admin.options import StackedInline, TabularInline
    33from django.contrib.admin.sites import AdminSite, site
    44
     5valid_apps_admin = []
     6
    57def autodiscover():
    68    """
    79    Auto-discover INSTALLED_APPS admin.py modules and fail silently when
    def autodiscover():  
    1012    """
    1113    import imp
    1214    from django.conf import settings
     15
    1316    for app in settings.INSTALLED_APPS:
    14         try:
    15             imp.find_module("admin", __import__(app, {}, {}, [app.split(".")[-1]]).__path__)
    16         except ImportError:
    17             # there is no app admin.py, skip it
    18             continue
    19         __import__("%s.admin" % app)
     17
     18        if app not in valid_apps_admin:
     19
     20            try:
     21                imp.find_module("admin", __import__(app, {}, {}, [app.split(".")[-1]]).__path__)
     22            except ImportError:
     23                # there is no app admin.py, skip it
     24                continue
     25            try:
     26                __import__("%s.admin" % app)
     27            except:
     28                raise
     29            else:
     30                valid_apps_admin.append(app)
Back to Top