Loading docs/ref/contrib/admin/index.txt +32 −11 Original line number Diff line number Diff line Loading @@ -2411,18 +2411,13 @@ creating your own ``AdminSite`` instance (see below), and changing the this class is created as ``django.contrib.admin.site`` and you can register your models and ``ModelAdmin`` instances with it. If you'd like to set up your own administrative site with custom behavior, however, you're free to subclass ``AdminSite`` and override or add anything you like. Then, simply create an instance of your ``AdminSite`` subclass (the same way you'd instantiate any other Python class), and register your models and ``ModelAdmin`` subclasses with it instead of using the default. When constructing an instance of an ``AdminSite``, you can provide a unique instance name using the ``name`` argument to the constructor. This instance name is used to identify the instance, especially when :ref:`reversing admin URLs <admin-reverse-urls>`. If no instance name is provided, a default instance name of ``admin`` will be used. See :ref:`customizing-adminsite` for an example of customizing the :class:`AdminSite` class. ``AdminSite`` attributes ------------------------ Loading Loading @@ -2501,12 +2496,38 @@ In this example, we register the default ``AdminSite`` instance (r'^admin/', include(admin.site.urls)), ) In this example, we register the ``AdminSite`` instance ``myproject.admin.admin_site`` at the URL ``/myadmin/`` :: .. _customizing-adminsite: Customizing the :class:`AdminSite` class ---------------------------------------- If you'd like to set up your own admin site with custom behavior, you're free to subclass ``AdminSite`` and override or add anything you like. Then, simply create an instance of your ``AdminSite`` subclass (the same way you'd instantiate any other Python class) and register your models and ``ModelAdmin`` subclasses with it instead of with the default site. Finally, update :file:`myproject/urls.py` to reference your :class:`AdminSite` subclass. .. snippet:: :filename: myapp/admin.py from django.contrib.admin import AdminSite from .models import MyModel class MyAdminSite(AdminSite): site_header = 'Monty Python administration' admin_site = MyAdminSite(name='myadmin') admin_site.register(MyModel) .. snippet:: :filename: myproject/urls.py # urls.py from django.conf.urls import patterns, include from myproject.admin import admin_site from myapp.admin import admin_site urlpatterns = patterns('', (r'^myadmin/', include(admin_site.urls)), Loading Loading
docs/ref/contrib/admin/index.txt +32 −11 Original line number Diff line number Diff line Loading @@ -2411,18 +2411,13 @@ creating your own ``AdminSite`` instance (see below), and changing the this class is created as ``django.contrib.admin.site`` and you can register your models and ``ModelAdmin`` instances with it. If you'd like to set up your own administrative site with custom behavior, however, you're free to subclass ``AdminSite`` and override or add anything you like. Then, simply create an instance of your ``AdminSite`` subclass (the same way you'd instantiate any other Python class), and register your models and ``ModelAdmin`` subclasses with it instead of using the default. When constructing an instance of an ``AdminSite``, you can provide a unique instance name using the ``name`` argument to the constructor. This instance name is used to identify the instance, especially when :ref:`reversing admin URLs <admin-reverse-urls>`. If no instance name is provided, a default instance name of ``admin`` will be used. See :ref:`customizing-adminsite` for an example of customizing the :class:`AdminSite` class. ``AdminSite`` attributes ------------------------ Loading Loading @@ -2501,12 +2496,38 @@ In this example, we register the default ``AdminSite`` instance (r'^admin/', include(admin.site.urls)), ) In this example, we register the ``AdminSite`` instance ``myproject.admin.admin_site`` at the URL ``/myadmin/`` :: .. _customizing-adminsite: Customizing the :class:`AdminSite` class ---------------------------------------- If you'd like to set up your own admin site with custom behavior, you're free to subclass ``AdminSite`` and override or add anything you like. Then, simply create an instance of your ``AdminSite`` subclass (the same way you'd instantiate any other Python class) and register your models and ``ModelAdmin`` subclasses with it instead of with the default site. Finally, update :file:`myproject/urls.py` to reference your :class:`AdminSite` subclass. .. snippet:: :filename: myapp/admin.py from django.contrib.admin import AdminSite from .models import MyModel class MyAdminSite(AdminSite): site_header = 'Monty Python administration' admin_site = MyAdminSite(name='myadmin') admin_site.register(MyModel) .. snippet:: :filename: myproject/urls.py # urls.py from django.conf.urls import patterns, include from myproject.admin import admin_site from myapp.admin import admin_site urlpatterns = patterns('', (r'^myadmin/', include(admin_site.urls)), Loading