Ticket #8245: Misleading-AlreadyRegistered-01.diff

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

another solution, would this work?

  • django/contrib/admin/__init__.py

    diff --git a/django/contrib/admin/__init__.py b/django/contrib/admin/__init__.py
    index 704dc58..86589a5 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
    13     for app in settings.INSTALLED_APPS:
     15    for app in settings.INSTALLED_APPS and app not in valid_apps_admin:
    1416        try:
    1517            imp.find_module("admin", __import__(app, {}, {}, [app.split(".")[-1]]).__path__)
    1618        except ImportError:
    1719            # there is no app admin.py, skip it
    1820            continue
    19         __import__("%s.admin" % app)
     21        try:
     22            __import__("%s.admin" % app)
     23        except:
     24            raise
     25        else:
     26            valid_apps_admin.append(app)
Back to Top