From 83623d45c754dff956a3bc90ee34e35bca8a1bce Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 16 Apr 2009 12:46:58 +0000 Subject: [PATCH] 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. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10564 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/contrib/admin/index.txt | 106 ++++++++++++------------------- docs/ref/models/fields.txt | 4 ++ 2 files changed, 46 insertions(+), 64 deletions(-) diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 463829538a..4b1d002b9c 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.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 @@ -46,7 +48,7 @@ Other topics :maxdepth: 1 actions - + .. seealso:: For information about serving the media files (images, JavaScript, and CSS) @@ -55,6 +57,8 @@ Other topics ``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``:: @@ -90,8 +94,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 @@ -101,8 +104,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 @@ -111,8 +113,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. @@ -191,8 +192,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 @@ -211,8 +211,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. @@ -237,22 +236,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 @@ -538,8 +525,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 (