Ticket #8500: 8500.1.diff

File 8500.1.diff, 3.8 KB (added by Jannis Leidel, 15 years ago)

updated patch from #8572 by msaelices

  • django/contrib/admin/__init__.py

    diff --git a/django/contrib/admin/__init__.py b/django/contrib/admin/__init__.py
    index abc5f09..ddaac3e 100644
    a b from django.utils.importlib import import_module  
    88# True while running, and False when it finishes.
    99LOADING = False
    1010
    11 def autodiscover():
     11def autodiscover(admin_site=None):
    1212    """
    1313    Auto-discover INSTALLED_APPS admin.py modules and fail silently when
    1414    not present. This forces an import on them to register any admin bits they
    def autodiscover():  
    2727    import imp
    2828    from django.conf import settings
    2929
     30    if admin_site is None:
     31        admin_site = site
     32
    3033    for app in settings.INSTALLED_APPS:
    3134        # For each app, we need to look for an admin.py inside that app's
    3235        # package. We can't use os.path here -- recall that modules may be
    def autodiscover():  
    5558        # Step 3: import the app's admin file. If this has errors we want them
    5659        # to bubble up.
    5760        import_module("%s.admin" % app)
     61
     62        # Step 4: look for register function and call it, passing admin site
     63        # as parameter
     64        register_func = getattr(mod, 'register', None)
     65        if register_func is not None and callable(register_func):
     66            register_func(admin_site)
    5867    # autodiscover was successful, reset loading flag.
    5968    LOADING = False
  • django/contrib/auth/admin.py

    diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
    index 61bae28..e06b601 100644
    a b class UserAdmin(admin.ModelAdmin):  
    138138        }, context_instance=RequestContext(request))
    139139
    140140
    141 admin.site.register(Group, GroupAdmin)
    142 admin.site.register(User, UserAdmin)
    143 
     141def register(site):
     142    site.register(Group, GroupAdmin)
     143    site.register(User, UserAdmin)
  • django/contrib/comments/admin.py

    diff --git a/django/contrib/comments/admin.py b/django/contrib/comments/admin.py
    index ede833f..7ed91de 100644
    a b class CommentsAdmin(admin.ModelAdmin):  
    6565# Only register the default admin if the model is the built-in comment model
    6666# (this won't be true if there's a custom comment app).
    6767if get_model() is Comment:
    68     admin.site.register(Comment, CommentsAdmin)
     68    def register(site):
     69        site.register(Comment, CommentsAdmin)
  • django/contrib/flatpages/admin.py

    diff --git a/django/contrib/flatpages/admin.py b/django/contrib/flatpages/admin.py
    index b6fdba3..1fc5631 100644
    a b class FlatPageAdmin(admin.ModelAdmin):  
    2525    list_filter = ('sites', 'enable_comments', 'registration_required')
    2626    search_fields = ('url', 'title')
    2727
    28 admin.site.register(FlatPage, FlatPageAdmin)
     28def register(site):
     29    site.register(FlatPage, FlatPageAdmin)
  • django/contrib/redirects/admin.py

    diff --git a/django/contrib/redirects/admin.py b/django/contrib/redirects/admin.py
    index a9b2a32..15662fb 100644
    a b  
    1 
    21from django.contrib import admin
    32from django.contrib.redirects.models import Redirect
    43
    class RedirectAdmin(admin.ModelAdmin):  
    87    search_fields = ('old_path', 'new_path')
    98    radio_fields = {'site': admin.VERTICAL}
    109
    11 admin.site.register(Redirect, RedirectAdmin)
    12  No newline at end of file
     10def register(site):
     11    site.register(Redirect, RedirectAdmin)
  • django/contrib/sites/admin.py

    diff --git a/django/contrib/sites/admin.py b/django/contrib/sites/admin.py
    index 2442c24..2102fa2 100644
    a b class SiteAdmin(admin.ModelAdmin):  
    66    list_display = ('domain', 'name')
    77    search_fields = ('domain', 'name')
    88
    9 admin.site.register(Site, SiteAdmin)
    10  No newline at end of file
     9def register(site):
     10    site.register(Site, SiteAdmin)
Back to Top