1 # ACTION_CHECKBOX_NAME is unused, but should stay since its import from here
2 # has been referenced in documentation.
3 from django
.contrib
.admin
.helpers
import ACTION_CHECKBOX_NAME
4 from django
.contrib
.admin
.options
import ModelAdmin
, HORIZONTAL
, VERTICAL
5 from django
.contrib
.admin
.options
import StackedInline
, TabularInline
6 from django
.contrib
.admin
.sites
import AdminSite
, site
7 from django
.contrib
.admin
.filters
import (ListFilter
, SimpleListFilter
,
8 FieldListFilter
, BooleanFieldListFilter
, RelatedFieldListFilter
,
9 ChoicesFieldListFilter
, DateFieldListFilter
, AllValuesFieldListFilter
)
14 Auto-discover INSTALLED_APPS admin.py modules and fail silently when
15 not present. This forces an import on them to register any admin bits they
20 from django
.conf
import settings
21 from django
.utils
.importlib
import import_module
22 from django
.utils
.module_loading
import module_has_submodule
24 for app
in settings
.INSTALLED_APPS
:
25 mod
= import_module(app
)
26 # Attempt to import the app's admin module.
28 before_import_registry
= copy
.copy(site
._registry
)
29 import_module('%s.admin' % app
)
31 # Reset the model registry to the state before the last import as
32 # this import will have to reoccur on the next request and this
33 # could raise NotRegistered and AlreadyRegistered exceptions
35 site
._registry
= before_import_registry
37 # Decide whether to bubble up this error. If the app just
38 # doesn't have an admin module, we can ignore the error
39 # attempting to import it, otherwise we want it to bubble up.
40 if module_has_submodule(mod
, 'admin'):