mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Polished the admin overview docs.
This commit is contained in:
parent
ef87b38ef7
commit
939dcff24f
@ -25,41 +25,39 @@ Overview
|
|||||||
The admin is enabled in the default project template used by
|
The admin is enabled in the default project template used by
|
||||||
:djadmin:`startproject`.
|
:djadmin:`startproject`.
|
||||||
|
|
||||||
For reference, here are the requirements:
|
If you're not using the default project template, here are the requirements:
|
||||||
|
|
||||||
1. Add ``'django.contrib.admin'`` to your :setting:`INSTALLED_APPS` setting.
|
#. Add ``'django.contrib.admin'`` and its dependencies -
|
||||||
|
:mod:`django.contrib.auth`, :mod:`django.contrib.contenttypes`,
|
||||||
|
:mod:`django.contrib.messages`, and :mod:`django.contrib.sessions` - to your
|
||||||
|
:setting:`INSTALLED_APPS` setting.
|
||||||
|
|
||||||
2. The admin has four dependencies - :mod:`django.contrib.auth`,
|
#. Configure a :class:`~django.template.backends.django.DjangoTemplates`
|
||||||
:mod:`django.contrib.contenttypes`,
|
backend in your :setting:`TEMPLATES` setting with
|
||||||
:mod:`django.contrib.messages` and
|
``django.contrib.auth.context_processors.auth`` and
|
||||||
:mod:`django.contrib.sessions`. If these applications are not
|
``django.contrib.messages.context_processors.messages`` in
|
||||||
in your :setting:`INSTALLED_APPS` list, add them.
|
the ``'context_processors'`` option of :setting:`OPTIONS
|
||||||
|
<TEMPLATES-OPTIONS>`.
|
||||||
|
|
||||||
3. Add ``django.contrib.auth.context_processors.auth`` and
|
#. If you've customized the :setting:`MIDDLEWARE` setting,
|
||||||
``django.contrib.messages.context_processors.messages`` to
|
|
||||||
the ``'context_processors'`` option of the ``DjangoTemplates`` backend
|
|
||||||
defined in your :setting:`TEMPLATES` as well as
|
|
||||||
:class:`django.contrib.auth.middleware.AuthenticationMiddleware` and
|
:class:`django.contrib.auth.middleware.AuthenticationMiddleware` and
|
||||||
:class:`django.contrib.messages.middleware.MessageMiddleware` to
|
:class:`django.contrib.messages.middleware.MessageMiddleware` must be
|
||||||
:setting:`MIDDLEWARE`. These are all active by default, so you only need to
|
included.
|
||||||
do this if you've manually tweaked the settings.
|
|
||||||
|
|
||||||
4. Determine which of your application's models should be editable in the
|
5. :ref:`Hook the admin's URLs into your URLconf
|
||||||
admin interface.
|
<hooking-adminsite-to-urlconf>`.
|
||||||
|
|
||||||
5. For each of those models, optionally create a ``ModelAdmin`` class that
|
After you've taken these steps, you'll be able to use the admin site by
|
||||||
encapsulates the customized admin functionality and options for that
|
visiting the URL you hooked it into (``/admin/``, by default).
|
||||||
particular model.
|
|
||||||
|
|
||||||
6. Instantiate an ``AdminSite`` and tell it about each of your models and
|
If you need to create a user to login with, use the :djadmin:`createsuperuser`
|
||||||
``ModelAdmin`` classes.
|
command. By default, logging in to the admin requires that the user has the
|
||||||
|
:attr:`~.User.is_superuser` or :attr:`~.User.is_staff` attribute set to
|
||||||
|
``True``.
|
||||||
|
|
||||||
7. Hook the ``AdminSite`` instance into your URLconf.
|
Finally, determine which of your application's models should be editable in the
|
||||||
|
admin interface. For each of those models, register them with the admin as
|
||||||
After you've taken these steps, you'll be able to use your Django admin site
|
described in :class:`ModelAdmin`.
|
||||||
by visiting the URL you hooked it into (``/admin/``, by default). If you need
|
|
||||||
to create a user to login with, you can use the :djadmin:`createsuperuser`
|
|
||||||
command.
|
|
||||||
|
|
||||||
Other topics
|
Other topics
|
||||||
------------
|
------------
|
||||||
@ -2898,6 +2896,8 @@ Templates can override or extend base admin templates as described in
|
|||||||
abstract. and ``django.contrib.admin.sites.AlreadyRegistered`` if a model
|
abstract. and ``django.contrib.admin.sites.AlreadyRegistered`` if a model
|
||||||
is already registered.
|
is already registered.
|
||||||
|
|
||||||
|
.. _hooking-adminsite-to-urlconf:
|
||||||
|
|
||||||
Hooking ``AdminSite`` instances into your URLconf
|
Hooking ``AdminSite`` instances into your URLconf
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user