Hello site
[auf_framonde.git] / eggs / Django-1.4.5-py2.7.egg / django / contrib / admin / __init__.py
CommitLineData
01b54c21
MN
1# ACTION_CHECKBOX_NAME is unused, but should stay since its import from here
2# has been referenced in documentation.
3from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
4from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
5from django.contrib.admin.options import StackedInline, TabularInline
6from django.contrib.admin.sites import AdminSite, site
7from django.contrib.admin.filters import (ListFilter, SimpleListFilter,
8 FieldListFilter, BooleanFieldListFilter, RelatedFieldListFilter,
9 ChoicesFieldListFilter, DateFieldListFilter, AllValuesFieldListFilter)
10
11
12def autodiscover():
13 """
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
16 may want.
17 """
18
19 import copy
20 from django.conf import settings
21 from django.utils.importlib import import_module
22 from django.utils.module_loading import module_has_submodule
23
24 for app in settings.INSTALLED_APPS:
25 mod = import_module(app)
26 # Attempt to import the app's admin module.
27 try:
28 before_import_registry = copy.copy(site._registry)
29 import_module('%s.admin' % app)
30 except:
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
34 # (see #8245).
35 site._registry = before_import_registry
36
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'):
41 raise