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
|
8 | 8 | # True while running, and False when it finishes. |
9 | 9 | LOADING = False |
10 | 10 | |
11 | | def autodiscover(): |
| 11 | def autodiscover(admin_site=None): |
12 | 12 | """ |
13 | 13 | Auto-discover INSTALLED_APPS admin.py modules and fail silently when |
14 | 14 | not present. This forces an import on them to register any admin bits they |
… |
… |
def autodiscover():
|
27 | 27 | import imp |
28 | 28 | from django.conf import settings |
29 | 29 | |
| 30 | if admin_site is None: |
| 31 | admin_site = site |
| 32 | |
30 | 33 | for app in settings.INSTALLED_APPS: |
31 | 34 | # For each app, we need to look for an admin.py inside that app's |
32 | 35 | # package. We can't use os.path here -- recall that modules may be |
… |
… |
def autodiscover():
|
55 | 58 | # Step 3: import the app's admin file. If this has errors we want them |
56 | 59 | # to bubble up. |
57 | 60 | 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) |
58 | 67 | # autodiscover was successful, reset loading flag. |
59 | 68 | LOADING = False |
diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
index 61bae28..e06b601 100644
a
|
b
|
class UserAdmin(admin.ModelAdmin):
|
138 | 138 | }, context_instance=RequestContext(request)) |
139 | 139 | |
140 | 140 | |
141 | | admin.site.register(Group, GroupAdmin) |
142 | | admin.site.register(User, UserAdmin) |
143 | | |
| 141 | def register(site): |
| 142 | site.register(Group, GroupAdmin) |
| 143 | site.register(User, UserAdmin) |
diff --git a/django/contrib/comments/admin.py b/django/contrib/comments/admin.py
index ede833f..7ed91de 100644
a
|
b
|
class CommentsAdmin(admin.ModelAdmin):
|
65 | 65 | # Only register the default admin if the model is the built-in comment model |
66 | 66 | # (this won't be true if there's a custom comment app). |
67 | 67 | if get_model() is Comment: |
68 | | admin.site.register(Comment, CommentsAdmin) |
| 68 | def register(site): |
| 69 | site.register(Comment, CommentsAdmin) |
diff --git a/django/contrib/flatpages/admin.py b/django/contrib/flatpages/admin.py
index b6fdba3..1fc5631 100644
a
|
b
|
class FlatPageAdmin(admin.ModelAdmin):
|
25 | 25 | list_filter = ('sites', 'enable_comments', 'registration_required') |
26 | 26 | search_fields = ('url', 'title') |
27 | 27 | |
28 | | admin.site.register(FlatPage, FlatPageAdmin) |
| 28 | def register(site): |
| 29 | site.register(FlatPage, FlatPageAdmin) |
diff --git a/django/contrib/redirects/admin.py b/django/contrib/redirects/admin.py
index a9b2a32..15662fb 100644
a
|
b
|
|
1 | | |
2 | 1 | from django.contrib import admin |
3 | 2 | from django.contrib.redirects.models import Redirect |
4 | 3 | |
… |
… |
class RedirectAdmin(admin.ModelAdmin):
|
8 | 7 | search_fields = ('old_path', 'new_path') |
9 | 8 | radio_fields = {'site': admin.VERTICAL} |
10 | 9 | |
11 | | admin.site.register(Redirect, RedirectAdmin) |
12 | | No newline at end of file |
| 10 | def register(site): |
| 11 | site.register(Redirect, RedirectAdmin) |
diff --git a/django/contrib/sites/admin.py b/django/contrib/sites/admin.py
index 2442c24..2102fa2 100644
a
|
b
|
class SiteAdmin(admin.ModelAdmin):
|
6 | 6 | list_display = ('domain', 'name') |
7 | 7 | search_fields = ('domain', 'name') |
8 | 8 | |
9 | | admin.site.register(Site, SiteAdmin) |
10 | | No newline at end of file |
| 9 | def register(site): |
| 10 | site.register(Site, SiteAdmin) |