1 ======================================
2 Customizing the Django admin interface
3 ======================================
5 Django's dynamic admin interface gives you a fully-functional admin for free
6 with no hand-coding required. The dynamic admin is designed to be
7 production-ready, not just a starting point, so you can use it as-is on a real
8 site. While the underlying format of the admin pages is built in to Django, you
9 can customize the look and feel by editing the admin stylesheet and images.
11 Here's a quick and dirty overview some of the main styles and classes used in
17 The ``.module`` class is a basic building block for grouping content in the
18 admin. It's generally applied to a ``div`` or a ``fieldset``. It wraps the content
19 group in a box and applies certain styles to the elements within. An ``h2``
20 within a ``div.module`` will align to the top of the ``div`` as a header for the
23 .. image:: http://media.djangoproject.com/img/doc/admincss/module.gif
24 :alt: Example use of module class on admin homepage
31 All admin pages (except the dashboard) are fluid-width. All fixed-width
32 classes from previous Django versions have been removed.
34 The base template for each admin page has a block that defines the column
35 structure for the page. This sets a class on the page content area
36 (``div#content``) so everything on the page knows how wide it should be. There
37 are three column types available.
40 This is the default column setting for all pages. The "M" stands for "main".
41 Assumes that all content on the page is in one main column
42 (``div#content-main``).
44 This is for pages with one main column and a sidebar on the right. The "S"
45 stands for "sidebar". Assumes that main content is in ``div#content-main``
46 and sidebar content is in ``div#content-related``. This is used on the main
49 Same as above, with the sidebar on the left. The source order of the columns
52 For instance, you could stick this in a template to make a two-column page with
53 the sidebar on the right::
55 {% block coltype %}colMS{% endblock %}
63 Most HTML elements (headers, lists, etc.) have base font sizes in the stylesheet
64 based on context. There are three classes are available for forcing text to a
65 certain size in any context.
74 Font Styles and Alignment
75 -------------------------
77 There are also a few styles for styling text.
80 Sets font color to light gray. Good for side notes in instructions. Combine
81 with ``.small`` or ``.tiny`` for sheer excitement.
83 This is a custom class for blocks of inline help text explaining the
84 function of form elements. It makes text smaller and gray, and when applied
85 to ``p`` elements within ``.form-row`` elements (see Form Styles below),
86 it will offset the text to align with the form field. Use this for help
87 text, instead of ``small quiet``. It works on other elements, but try to
88 put the class on a ``p`` whenever you can.
90 It aligns the text left. Only works on block elements containing inline
93 Are you paying attention?
95 Keeps text and inline objects from wrapping. Comes in handy for table
96 headers you want to stay on one line.
111 Certain actions which apply directly to an object are used in form and
112 changelist pages. These appear in a "toolbar" row above the form or changelist,
113 to the right of the page. The tools are wrapped in a ``ul`` with the class
114 ``object-tools``. There are two custom tool types which can be defined with an
115 additional class on the ``a`` for that tool. These are ``.addlink`` and
118 Example from a changelist page::
120 <ul class="object-tools">
121 <li><a href="/stories/add/" class="addlink">Add redirect</a></li>
124 .. image:: http://media.djangoproject.com/img/doc/admincss/objecttools_01.gif
125 :alt: Object tools on a changelist page
127 and from a form page::
129 <ul class="object-tools">
130 <li><a href="/history/303/152383/">History</a></li>
131 <li><a href="/r/303/152383/" class="viewsitelink">View on site</a></li>
134 .. image:: http://media.djangoproject.com/img/doc/admincss/objecttools_02.gif
135 :alt: Object tools on a form page
143 Admin forms are broken up into groups by ``fieldset`` elements. Each form fieldset
144 should have a class ``.module``. Each fieldset should have a header ``h2`` within the
145 fieldset at the top (except the first group in the form, and in some cases where the
146 group of fields doesn't have a logical label).
148 Each fieldset can also take extra classes in addition to ``.module`` to apply
149 appropriate formatting to the group of fields.
152 This will align the labels and inputs side by side on the same line.
154 Used in combination with ``.aligned`` to widen the space available for the
160 Each row of the form (within the ``fieldset``) should be enclosed in a ``div``
161 with class ``form-row``. If the field in the row is required, a class of
162 ``required`` should also be added to the ``div.form-row``.
164 .. image:: http://media.djangoproject.com/img/doc/admincss/formrow.gif
165 :alt: Example use of form-row class
170 Form labels should always precede the field, except in the case
171 of checkboxes and radio buttons, where the ``input`` should come first. Any
172 explanation or help text should follow the ``label`` in a ``p`` with class