diff --git a/docs/admin.txt b/docs/admin.txt index 0d3cb811ee..e63131c7b9 100644 --- a/docs/admin.txt +++ b/docs/admin.txt @@ -46,6 +46,9 @@ Let's take a look at a very simple example the ``ModelAdmin``:: pass admin.site.register(Author, AuthorAdmin) +``ModelAdmin`` Options +---------------------- + The ``ModelAdmin`` is very flexible. It has several options for dealing with customizing the interface. All options are defined on the ``ModelAdmin`` subclass:: @@ -54,7 +57,7 @@ subclass:: date_hierarchy = 'pub_date' ``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 @@ -65,7 +68,7 @@ Example:: date_hierarchy = 'pub_date' ``fieldsets`` -------------- +~~~~~~~~~~~~~ Set ``fieldsets`` to control the layout of admin "add" and "change" pages. @@ -102,55 +105,49 @@ in the same order as the fields are defined in the model. The ``field_options`` dictionary can have the following keys: ``fields`` -~~~~~~~~~~ + A tuple of field names to display in this fieldset. This key is required. + + Example:: + + { + 'fields': ('first_name', 'last_name', 'address', 'city', 'state'), + } -A tuple of field names to display in this fieldset. This key is required. - -Example:: - - { - 'fields': ('first_name', 'last_name', 'address', 'city', 'state'), - } - -To display multiple fields on the same line, wrap those fields in their own -tuple. In this example, the ``first_name`` and ``last_name`` fields will -display on the same line:: - - { - 'fields': (('first_name', 'last_name'), 'address', 'city', 'state'), - } + To display multiple fields on the same line, wrap those fields in their own + tuple. In this example, the ``first_name`` and ``last_name`` fields will + display on the same line:: + + { + 'fields': (('first_name', 'last_name'), 'address', 'city', 'state'), + } ``classes`` -~~~~~~~~~~~ + A string containing extra CSS classes to apply to the fieldset. + + Example:: + + { + 'classes': 'wide', + } -A string containing extra CSS classes to apply to the fieldset. - -Example:: - - { - 'classes': 'wide', - } - -Apply multiple classes by separating them with spaces. Example:: - - { - 'classes': 'wide extrapretty', - } - -Two useful classes defined by the default admin-site stylesheet are -``collapse`` and ``wide``. Fieldsets with the ``collapse`` style will be -initially collapsed in the admin and replaced with a small "click to expand" -link. Fieldsets with the ``wide`` style will be given extra horizontal space. + Apply multiple classes by separating them with spaces. Example:: + + { + 'classes': 'wide extrapretty', + } + + Two useful classes defined by the default admin-site stylesheet are + ``collapse`` and ``wide``. Fieldsets with the ``collapse`` style will be + initially collapsed in the admin and replaced with a small "click to expand" + link. Fieldsets with the ``wide`` style will be given extra horizontal space. ``description`` -~~~~~~~~~~~~~~~ - -A string of optional extra text to be displayed at the top of each fieldset, -under the heading of the fieldset. It's used verbatim, so you can use any HTML -and you must escape any special HTML characters (such as ampersands) yourself. + A string of optional extra text to be displayed at the top of each fieldset, + under the heading of the fieldset. It's used verbatim, so you can use any HTML + and you must escape any special HTML characters (such as ampersands) yourself. ``list_display`` ----------------- +~~~~~~~~~~~~~~~~ Set ``list_display`` to control which fields are displayed on the change list page of the admin. @@ -261,7 +258,7 @@ A few special cases to note about ``list_display``: trying to sort by ``colored_first_name`` in the admin. ``list_display_links`` ----------------------- +~~~~~~~~~~~~~~~~~~~~~~ Set ``list_display_links`` to control which fields in ``list_display`` should be linked to the "change" page for an object. @@ -288,7 +285,7 @@ Finally, note that in order to use ``list_display_links``, you must define ``list_display``, too. ``list_filter`` ---------------- +~~~~~~~~~~~~~~~ Set ``list_filter`` to activate filters in the right sidebar of the change list page of the admin. This should be a list of field names, and each specified @@ -309,13 +306,13 @@ The above code results in an admin change list page that looks like this: (This example also has ``search_fields`` defined. See below.) ``list_per_page`` ------------------ +~~~~~~~~~~~~~~~~~ Set ``list_per_page`` to control how many items appear on each paginated admin change list page. By default, this is set to ``100``. ``list_select_related`` ------------------------ +~~~~~~~~~~~~~~~~~~~~~~~ Set ``list_select_related`` to tell Django to use ``select_related()`` in retrieving the list of objects on the admin change list page. This can save you @@ -331,12 +328,12 @@ For more on ``select_related()``, see `the select_related() docs`_. .. _the select_related() docs: ../db-api/#select-related ``inlines`` ------------ +~~~~~~~~~~~ See ``InlineModelAdmin`` objects below. ``ordering`` ------------- +~~~~~~~~~~~~ Set ``ordering`` to specify how objects on the admin change list page should be ordered. This should be a list or tuple in the same format as a model's @@ -345,7 +342,7 @@ ordered. This should be a list or tuple in the same format as a model's If this isn't provided, the Django admin will use the model's default ordering. ``radio_fields`` ----------------- +~~~~~~~~~~~~~~~~ By default, Django's admin uses a select-box interface (