We place a high importance on consistency and readability of documentation.
After all, Django was created in a journalism environment! So we treat our
documentation like we treat our code: we aim to improve it as often as
possible.

Documentation changes generally come in two forms:

General improvements: typo corrections, error fixes and better
explanations through clearer writing and more examples.

New features: documentation of features that have been added to the
framework since the last release.

This section explains how writers can craft their documentation changes
in the most useful and least error-prone ways.

Though Django’s documentation is intended to be read as HTML at
https://docs.djangoproject.com/, we edit it as a collection of text files for
maximum flexibility. These files live in the top-level docs/ directory of a
Django release.

If you’d like to start contributing to our docs, get the development version of
Django from the source code repository
(see Installing the development version). The development version has the
latest-and-greatest documentation, just as it has latest-and-greatest code.
We also backport documentation fixes and improvements, at the discretion of the
committer, to the last release branch. That’s because it’s highly advantageous
to have the docs for the last release be up-to-date and correct (see
Differences between versions).

Django’s documentation uses the Sphinx documentation system, which in turn
is based on docutils. The basic idea is that lightly-formatted plain-text
documentation is transformed into HTML, PDF, and any other output format.

To actually build the documentation locally, you’ll currently need to install
Sphinx – pipinstallSphinx should do the trick.

Then, building the HTML is easy; just makehtml (or make.bathtml on
Windows) from the docs directory.

Your locally-built documentation will be themed differently than the
documentation at docs.djangoproject.com.
This is OK! If your changes look good on your local machine, they’ll look good
on the website.

Tutorials take the reader by the hand through a series
of steps to create something.

The important thing in a tutorial is to help the reader achieve something
useful, preferably as early as possible, in order to give them confidence.

Explain the nature of the problem we’re solving, so that the reader
understands what we’re trying to achieve. Don’t feel that you need to begin
with explanations of how things work - what matters is what the reader does,
not what you explain. It can be helpful to refer back to what you’ve done and
explain afterwards.

Topic guides aim to explain a concept or subject at a
fairly high level.

Link to reference material rather than repeat it. Use examples and don’t be
reluctant to explain things that seem very basic to you - it might be the
explanation someone else needs.

Providing background context helps a newcomer connect the topic to things
that they already know.

Reference guides contain technical reference for APIs.
They describe the functioning of Django’s internal machinery and instruct in
its use.

Keep reference material tightly focused on the subject. Assume that the
reader already understands the basic concepts involved but needs to know or
be reminded of how Django does it.

Reference guides aren’t the place for general explanation. If you find
yourself explaining basic concepts, you may want to move that material to a
topic guide.

How-to guides are recipes that take the reader through
steps in key subjects.

What matters most in a how-to guide is what a user wants to achieve.
A how-to should always be result-oriented rather than focused on internal
details of how Django implements whatever is being discussed.

These guides are more advanced than tutorials and assume some knowledge about
how Django works. Assume that the reader has followed the tutorials and don’t
hesitate to refer the reader back to the appropriate tutorial rather than
repeat the same material.

Add ..code-block::<lang> to literal blocks so that they get
highlighted. Prefer relying on automatic highlighting simply using ::
(two colons). This has the benefit that if the code contains some invalid
syntax, it won’t be highlighted. Adding ..code-block::python, for
example, will force highlighting despite invalid syntax.

All documentation of new features should be written in a way that
clearly designates the features are only available in the Django
development version. Assume documentation readers are using the latest
release, not the development version.

Our preferred way for marking new features is by prefacing the features’
documentation with: “..versionadded::X.Y”, followed by a mandatory
blank line and an optional description (indented).

General improvements, or other changes to the APIs that should be emphasized
should use the “..versionchanged::X.Y” directive (with the same format
as the versionadded mentioned above.

These versionadded and versionchanged blocks should be “self-contained.”
In other words, since we only keep these annotations around for two releases,
it’s nice to be able to remove the annotation and its contents without having
to reflow, reindent, or edit the surrounding text. For example, instead of
putting the entire description of a new or changed feature in a block, do
something like this:

Put the changed annotation notes at the bottom of a section, not the top.

Also, avoid referring to a specific version of Django outside a
versionadded or versionchanged block. Even inside a block, it’s often
redundant to do so as these annotations render as “New in Django A.B:” and
“Changed in Django A.B”, respectively.

If a function, attribute, etc. is added, it’s also okay to use a
versionadded annotation like this:

Next, the topics/settings.txt document could contain something like
this:

You can access a :ref:`listing of all available settings
<available-settings>`. For a list of deprecated settings see
:ref:`deprecated-settings`.
You can find both in the :doc:`settings reference document
</ref/settings>`.

We use the Sphinx doc cross reference element when we want to
link to another document as a whole and the ref element when
we want to link to an arbitrary location in a document.

Next, notice how the settings are annotated:

..setting:: ADMINS
ADMINS======
Default: ``[]`` (Empty list)
A list of all the people who get code error notifications. When
``DEBUG=False`` and a view raises an exception, Django will email these people
with the full exception information. Each member of the list should be a tuple
of (Full name, email address). Example:: [('John', 'john@example.com'), ('Mary', 'mary@example.com')]
Note that Django will email *all* of these people whenever an error happens.
See :doc:`/howto/error-reporting` for more information.

This marks up the following header as the “canonical” target for the
setting ADMINS. This means any time I talk about ADMINS,
I can reference it using :setting:`ADMINS`.

Sphinx can generate a manual page for the
django-admin command. This is configured in
docs/conf.py. Unlike other documentation output, this man page should be
included in the Django repository and the releases as
docs/man/django-admin.1. There isn’t a need to update this file when
updating the documentation, as it’s updated once as part of the release process.

To generate an updated version of the man page, run makeman in the
docs directory. The new man page will be written in
docs/_build/man/django-admin.1.

This document is for Django's development version, which can be significantly different from previous releases. For older releases, use the version selector floating in the bottom right corner of this page.