Django

Code

Changeset 6328

Show
Ignore:
Timestamp:
09/15/07 15:28:26 (1 year ago)
Author:
adrian
Message:

newforms-admin: Added more to docs/admin.txt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin/docs/admin.txt

    r6326 r6328  
    1313    The admin site has been refactored significantly since Django 0.96. This 
    1414    document describes the newest version of the admin site, which allows for 
    15     much richer customization. If you've kept up with Django development, you 
    16     may have heard this described as "newforms-admin." 
     15    much richer customization. If you follow the development of Django itself, 
     16    you may have heard this described as "newforms-admin." 
     17 
     18Overview 
     19======== 
     20 
     21There are four steps in activating the Django admin site: 
     22 
     23    1. Determine which of your application's models should be editable in the 
     24       admin interface. 
     25 
     26    2. For each of those models, optionally create a ``ModelAdmin`` class that 
     27       encapsulates the customized admin functionality and options for that 
     28       particular model. 
     29 
     30    3. Instantiate an ``AdminSite`` and tell it about each of your models and 
     31       ``ModelAdmin`` classes. 
     32 
     33    4. Hook the ``AdminSite`` instance into your URLconf. 
     34 
     35``ModelAdmin`` objects 
     36====================== 
     37 
     38``AdminSite`` objects 
     39===================== 
     40 
     41Hooking ``AdminSite`` instances into your URLconf 
     42================================================= 
     43 
     44The last step in setting up the Django admin is to hook your ``AdminSite`` 
     45instance into your URLconf. Do this by pointing a given URL at the 
     46``AdminSite.root`` method. 
     47 
     48In this example, we register the ``AdminSite`` instance 
     49``myproject.admin.admin_site`` at the URL ``/admin/`` :: 
     50 
     51    from django.conf.urls.defaults import * 
     52    from myproject.admin import admin_site 
     53 
     54    urlpatterns = patterns('', 
     55        ('^admin/(.*)', admin_site.root), 
     56    ) 
     57 
     58In this example, we register the default ``AdminSite`` instance 
     59``django.contrib.admin.site`` at the URL ``/myadmin/`` :: 
     60 
     61    from django.conf.urls.defaults import * 
     62    from django.contrib import admin 
     63 
     64    urlpatterns = patterns('', 
     65        ('^myadmin/(.*)', admin.site.root), 
     66    ) 
     67 
     68Note that the regular expression in the URLpattern *must* group everything in 
     69the URL that comes after the URL root -- hence the ``(.*)`` in these examples.