Django

Code

root/django/branches/newforms-admin/django/contrib/admin/__init__.py

Revision 7872, 0.6 kB (checked in by brosner, 2 months ago)

newforms-admin: Added autodiscover functionality to django.contrib.admin. This makes the admin aware of per-app admin.py modules and does an import on them when explicitly called. Docs show how this is used. Fixed #6003, #6776, #6776.

  • Property svn:eol-style set to native
Line 
1 from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
2 from django.contrib.admin.options import StackedInline, TabularInline
3 from django.contrib.admin.sites import AdminSite, site
4
5 def autodiscover():
6     """
7     Auto-discover INSTALLED_APPS admin.py modules and fail silently when
8     not present. This forces an import on them to register any admin bits they
9     may want.
10     """
11     from django.conf import settings
12     for app in settings.INSTALLED_APPS:
13         try:
14             __import__("%s.admin" % app)
15         except ImportError:
16             pass
Note: See TracBrowser for help on using the browser.