From e249b0ec4d8bb3880883927a1c732d882bcdfa48 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 16 Apr 2009 13:28:58 +0000 Subject: [PATCH] [1.0.X] Fixed #10776 -- Added metadata targets for the contrib.admin docs, and used one of those targets to clarify the SlugField docs. Thanks to ernop for the suggestion, and timo for the patch. Merge of r10564 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10570 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/contrib/admin.txt | 74 +++++++++++++++----------------------- docs/ref/models/fields.txt | 4 +++ 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/docs/ref/contrib/admin.txt b/docs/ref/contrib/admin.txt index 7444937a68..9ac339e99b 100644 --- a/docs/ref/contrib/admin.txt +++ b/docs/ref/contrib/admin.txt @@ -7,6 +7,8 @@ The Django admin site .. module:: django.contrib.admin :synopsis: Django's admin site. +.. currentmodule:: django.contrib.admin + One of the most powerful parts of Django is the automatic admin interface. It reads metadata in your model to provide a powerful and production-ready interface that content producers can immediately use to start adding content to @@ -38,7 +40,7 @@ There are five steps in activating the Django admin site: ``ModelAdmin`` classes. 5. Hook the ``AdminSite`` instance into your URLconf. - + .. seealso:: For information about serving the media files (images, JavaScript, and CSS) @@ -47,6 +49,8 @@ There are five steps in activating the Django admin site: ``ModelAdmin`` objects ====================== +.. class:: ModelAdmin + The ``ModelAdmin`` class is the representation of a model in the admin interface. These are stored in a file named ``admin.py`` in your application. Let's take a look at a very simple example of the ``ModelAdmin``:: @@ -82,8 +86,7 @@ subclass:: class AuthorAdmin(admin.ModelAdmin): date_hierarchy = 'pub_date' -``date_hierarchy`` -~~~~~~~~~~~~~~~~~~ +.. attribute:: ModelAdmin.date_hierarchy Set ``date_hierarchy`` to the name of a ``DateField`` or ``DateTimeField`` in your model, and the change list page will include a date-based drilldown @@ -93,8 +96,7 @@ Example:: date_hierarchy = 'pub_date' -``form`` -~~~~~~~~ +.. attribute:: ModelAdmin.form By default a ``ModelForm`` is dynamically created for your model. It is used to create the form presented on both the add/change pages. You can easily @@ -103,8 +105,7 @@ add/change pages. For an example see the section `Adding custom validation to the admin`_. -``fieldsets`` -~~~~~~~~~~~~~ +.. attribute:: ModelAdmin.fieldsets Set ``fieldsets`` to control the layout of admin "add" and "change" pages. @@ -183,8 +184,7 @@ The ``field_options`` dictionary can have the following keys: ``django.utils.html.escape()`` to escape any HTML special characters. -``fields`` -~~~~~~~~~~ +.. attribute:: ModelAdmin.fields Use this option as an alternative to ``fieldsets`` if the layout does not matter and if you want to only show a subset of the available fields in the @@ -203,8 +203,7 @@ displayed, sequentially, in the form. dictionary key that is within the ``fieldsets`` option, as described in the previous section. -``exclude`` -~~~~~~~~~~~ +.. attribute:: ModelAdmin.exclude This attribute, if given, should be a list of field names to exclude from the form. @@ -229,22 +228,19 @@ Since the Author model only has three fields, ``name``, ``title``, and ``birth_date``, the forms resulting from the above declarations will contain exactly the same fields. -``filter_horizontal`` -~~~~~~~~~~~~~~~~~~~~~ +.. attribute:: ModelAdmin.filter_horizontal Use a nifty unobtrusive JavaScript "filter" interface instead of the usability-challenged ``) for fields that are ``ForeignKey`` or have ``choices`` set. If a field is present @@ -502,8 +490,7 @@ You have the choice of using ``HORIZONTAL`` or ``VERTICAL`` from the Don't include a field in ``radio_fields`` unless it's a ``ForeignKey`` or has ``choices`` set. -``raw_id_fields`` -~~~~~~~~~~~~~~~~~ +.. attribute:: ModelAdmin.raw_id_fields By default, Django's admin uses a select-box interface (