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
29 The base template for each admin page has a block that defines the column
30 structure for the page. This sets a class on the page content area
31 (``div#content``) so everything on the page knows how wide it should be. So far
32 there are three options available, and one special hybrid option.
35 This is the default column setting for all pages. The "M" stands for "main".
36 Assumes that all content on the page is in one main column
37 (``div#content-main``).
39 This is for pages with one main column and a sidebar on the right. The "S"
40 stands for "sidebar". Assumes that main content is in ``div#content-main``
41 and sidebar content is in ``div#content-related``. This is used on the main
44 Same as above, with the sidebar on the left. The source order of the columns
47 This is for ridiculously wide pages. Doesn't really work very well for
48 anything but colM. With superwide, you've got 1000px to work with. Don't
51 This is for liquid-width pages, such as changelists. Currently only works
52 with single-column pages (does not combine with ``.colMS`` or ``.colSM``).
53 Form pages should never use ``.flex``.
55 For instance, you could stick this in a template to make a superwide page::
57 {% block coltype %}colM superwide{% endblock %}
59 or this to make a liquid-width page (note that ``flex`` replaces ``colM``, so
60 both classes are not required)::
62 {% block coltype %}flex{% endblock %}
67 There's a whole mess of classes in the stylesheet for custom pixel widths on
68 objects. They come in handy for tables and table cells, if you want to avoid
69 using the ``width`` attribute. Each class sets the width to the number of pixels
70 in the class, except ``.xfull`` which will always be the width of the column
71 it's in. (This helps with tables that you want to always fill the horizontal
72 width, without using ``width="100%"`` which makes IE 5's box model cry.)
74 **Note:** Within a ``.flex`` page, the ``.xfull`` class will ``usually`` set
75 to 100%, but there are exceptions and still some untested cases.
77 Available width classes::
79 .x50 .x75 .x100 .x150 .x200 .x250 .x300 .x400 .x500 .xfull
87 Most HTML elements (headers, lists, etc.) have base font sizes in the stylesheet
88 based on context. There are three classes are available for forcing text to a
89 certain size in any context.
98 Font Styles and Alignment
99 -------------------------
101 There are also a few styles for styling text.
104 Sets font color to light gray. Good for side notes in instructions. Combine
105 with ``.small`` or ``.tiny`` for sheer excitement.
107 This is a custom class for blocks of inline help text explaining the
108 function of form elements. It makes text smaller and gray, and when applied
109 to ``p`` elements withing ``.form-row`` elements (see Form Styles below), it will
110 offset the text to align with the form field. Use this for help text,
111 instead of ``small quiet``. It works on other elements, but try to put the class
112 on a ``p`` whenever you can.
114 It aligns the text left. Only works on block elements containing inline elements.
116 Are you paying attention?
118 Keeps text and inline objects from wrapping. Comes in handy for table headers you want to stay
134 Certain actions which apply directly to an object are used in form and
135 changelist pages. These appear in a "toolbar" row above the form or changelist,
136 to the right of the page. The tools are wrapped in a ``ul`` with the class
137 ``object-tools``. There are two custom tool types which can be defined with an
138 additional class on the ``a`` for that tool. These are ``.addlink`` and
141 Example from a changelist page::
143 <ul class="object-tools">
144 <li><a href="/stories/add/" class="addlink">Add redirect</a></li>
147 .. image:: http://media.djangoproject.com/img/doc/admincss/objecttools_01.gif
148 :alt: Object tools on a changelist page
150 and from a form page::
152 <ul class="object-tools">
153 <li><a href="/history/303/152383/">History</a></li>
154 <li><a href="/r/303/152383/" class="viewsitelink">View on site</a></li>
157 .. image:: http://media.djangoproject.com/img/doc/admincss/objecttools_02.gif
158 :alt: Object tools on a form page
166 Admin forms are broken up into groups by ``fieldset`` elements. Each form fieldset
167 should have a class ``.module``. Each fieldset should have a header ``h2`` within the
168 fieldset at the top (except the first group in the form, and in some cases where the
169 group of fields doesn't have a logical label).
171 Each fieldset can also take extra classes in addition to ``.module`` to apply
172 appropriate formatting to the group of fields.
175 this will align the labels and inputs side by side on the same line.
177 used in combination with ``.aligned`` to widen the space available for the labels.
182 Each row of the form (within the ``fieldset``) should be enclosed in a ``div``
183 with class ``form-row``. If the field in the row is required, a class of
184 ``required`` should also be added to the ``div.form-row``.
186 .. image:: http://media.djangoproject.com/img/doc/admincss/formrow.gif
187 :alt: Example use of form-row class
192 Form labels should always precede the field, except in the case
193 of checkboxes and radio buttons, where the ``input`` should come first. Any
194 explanation or help text should follow the ``label`` in a ``p`` with class