mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #23067 -- Updated docs to use django-admin
This commit is contained in:
committed by
Tim Graham
parent
66630f589c
commit
d47409831f
@@ -50,7 +50,7 @@ Installation
|
||||
|
||||
Authentication support is bundled as a Django contrib module in
|
||||
``django.contrib.auth``. By default, the required configuration is already
|
||||
included in the :file:`settings.py` generated by :djadmin:`django-admin.py
|
||||
included in the :file:`settings.py` generated by :djadmin:`django-admin
|
||||
startproject <startproject>`, these consist of two items listed in your
|
||||
:setting:`INSTALLED_APPS` setting:
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ particular application directly into your database prompt, like this::
|
||||
Using other management commands
|
||||
-------------------------------
|
||||
|
||||
The other ``django-admin.py`` commands that interact with the database
|
||||
The other ``django-admin`` commands that interact with the database
|
||||
operate in the same way as :djadmin:`migrate` -- they only ever operate
|
||||
on one database at a time, using :djadminopt:`--database` to control
|
||||
the database used.
|
||||
|
||||
@@ -24,7 +24,7 @@ To activate a middleware component, add it to the
|
||||
|
||||
In :setting:`MIDDLEWARE_CLASSES`, each middleware component is represented by
|
||||
a string: the full Python path to the middleware's class name. For example,
|
||||
here's the default value created by :djadmin:`django-admin.py startproject
|
||||
here's the default value created by :djadmin:`django-admin startproject
|
||||
<startproject>`::
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
|
||||
@@ -20,7 +20,7 @@ To enable session functionality, do the following:
|
||||
|
||||
* Edit the :setting:`MIDDLEWARE_CLASSES` setting and make sure
|
||||
it contains ``'django.contrib.sessions.middleware.SessionMiddleware'``.
|
||||
The default ``settings.py`` created by ``django-admin.py startproject``
|
||||
The default ``settings.py`` created by ``django-admin startproject``
|
||||
has ``SessionMiddleware`` activated.
|
||||
|
||||
If you don't want to use sessions, you might as well remove the
|
||||
|
||||
@@ -20,7 +20,7 @@ necessary to set :setting:`USE_L10N = True <USE_L10N>` in your settings file.
|
||||
|
||||
.. note::
|
||||
|
||||
The default :file:`settings.py` file created by :djadmin:`django-admin.py
|
||||
The default :file:`settings.py` file created by :djadmin:`django-admin
|
||||
startproject <startproject>` includes :setting:`USE_L10N = True <USE_L10N>`
|
||||
for convenience. Note, however, that to enable number formatting with
|
||||
thousand separators it is necessary to set :setting:`USE_THOUSAND_SEPARATOR
|
||||
|
||||
@@ -40,7 +40,7 @@ or times, please try installing it before filing a bug. It's as simple as:
|
||||
|
||||
.. note::
|
||||
|
||||
The default :file:`settings.py` file created by :djadmin:`django-admin.py
|
||||
The default :file:`settings.py` file created by :djadmin:`django-admin
|
||||
startproject <startproject>` includes :setting:`USE_TZ = True <USE_TZ>`
|
||||
for convenience.
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ Translation works on variables. Again, here's an identical example::
|
||||
|
||||
(The caveat with using variables or computed values, as in the previous two
|
||||
examples, is that Django's translation-string-detecting utility,
|
||||
:djadmin:`django-admin.py makemessages <makemessages>`, won't be able to find
|
||||
:djadmin:`django-admin makemessages <makemessages>`, won't be able to find
|
||||
these strings. More on :djadmin:`makemessages` later.)
|
||||
|
||||
The strings you pass to ``_()`` or ``ugettext()`` can take placeholders,
|
||||
@@ -260,7 +260,7 @@ In a case like this, consider something like the following::
|
||||
'plural_name': Report._meta.verbose_name_plural
|
||||
}
|
||||
|
||||
You would get an error when running :djadmin:`django-admin.py
|
||||
You would get an error when running :djadmin:`django-admin
|
||||
compilemessages <compilemessages>`::
|
||||
|
||||
a format specification for argument 'name', as in 'msgstr[0]', doesn't exist in 'msgid'
|
||||
@@ -1235,7 +1235,7 @@ file is a plain-text file, representing a single language, that contains all
|
||||
available translation strings and how they should be represented in the given
|
||||
language. Message files have a ``.po`` file extension.
|
||||
|
||||
Django comes with a tool, :djadmin:`django-admin.py makemessages
|
||||
Django comes with a tool, :djadmin:`django-admin makemessages
|
||||
<makemessages>`, that automates the creation and upkeep of these files.
|
||||
|
||||
.. admonition:: Gettext utilities
|
||||
@@ -1248,7 +1248,7 @@ Django comes with a tool, :djadmin:`django-admin.py makemessages
|
||||
|
||||
To create or update a message file, run this command::
|
||||
|
||||
django-admin.py makemessages -l de
|
||||
django-admin makemessages -l de
|
||||
|
||||
...where ``de`` is the language code for the message file you want to create.
|
||||
The language code, in this case, is in :term:`locale format<locale name>`. For
|
||||
@@ -1279,17 +1279,17 @@ directory ``locale/LANG/LC_MESSAGES``. In the ``de`` example, the file will be
|
||||
:setting:`LOCALE_PATHS` or will generate an error if :setting:`LOCALE_PATHS`
|
||||
is empty.
|
||||
|
||||
By default :djadmin:`django-admin.py makemessages <makemessages>` examines every
|
||||
By default :djadmin:`django-admin makemessages <makemessages>` examines every
|
||||
file that has the ``.html`` or ``.txt`` file extension. In case you want to
|
||||
override that default, use the ``--extension`` or ``-e`` option to specify the
|
||||
file extensions to examine::
|
||||
|
||||
django-admin.py makemessages -l de -e txt
|
||||
django-admin makemessages -l de -e txt
|
||||
|
||||
Separate multiple extensions with commas and/or use ``-e`` or ``--extension``
|
||||
multiple times::
|
||||
|
||||
django-admin.py makemessages -l de -e html,txt -e xml
|
||||
django-admin makemessages -l de -e html,txt -e xml
|
||||
|
||||
.. warning::
|
||||
|
||||
@@ -1322,7 +1322,7 @@ For example, if your Django app contained a translation string for the text
|
||||
|
||||
_("Welcome to my site.")
|
||||
|
||||
...then :djadmin:`django-admin.py makemessages <makemessages>` will have created
|
||||
...then :djadmin:`django-admin makemessages <makemessages>` will have created
|
||||
a ``.po`` file containing the following snippet -- a message::
|
||||
|
||||
#: path/to/python/module.py:23
|
||||
@@ -1359,28 +1359,29 @@ otherwise, they'll be tacked together without whitespace!
|
||||
To reexamine all source code and templates for new translation strings and
|
||||
update all message files for **all** languages, run this::
|
||||
|
||||
django-admin.py makemessages -a
|
||||
django-admin makemessages -a
|
||||
|
||||
Compiling message files
|
||||
-----------------------
|
||||
|
||||
After you create your message file -- and each time you make changes to it --
|
||||
you'll need to compile it into a more efficient form, for use by ``gettext``. Do
|
||||
this with the :djadmin:`django-admin.py compilemessages <compilemessages>`
|
||||
this with the :djadmin:`django-admin compilemessages <compilemessages>`
|
||||
utility.
|
||||
|
||||
This tool runs over all available ``.po`` files and creates ``.mo`` files, which
|
||||
are binary files optimized for use by ``gettext``. In the same directory from
|
||||
which you ran :djadmin:`django-admin.py makemessages <makemessages>`, run :djadmin:`django-admin.py compilemessages <compilemessages>` like this::
|
||||
which you ran :djadmin:`django-admin makemessages <makemessages>`, run
|
||||
:djadmin:`django-admin compilemessages <compilemessages>` like this::
|
||||
|
||||
django-admin.py compilemessages
|
||||
django-admin compilemessages
|
||||
|
||||
That's it. Your translations are ready for use.
|
||||
|
||||
.. admonition:: Working on Windows?
|
||||
|
||||
If you're using Windows and need to install the GNU gettext utilities so
|
||||
:djadmin:`django-admin.py compilemessages <compilemessages>` works see
|
||||
:djadmin:`django-admin compilemessages <compilemessages>` works see
|
||||
:ref:`gettext_on_windows` for more information.
|
||||
|
||||
.. admonition:: .po files: Encoding and BOM usage.
|
||||
@@ -1395,15 +1396,15 @@ Creating message files from JavaScript source code
|
||||
--------------------------------------------------
|
||||
|
||||
You create and update the message files the same way as the other Django message
|
||||
files -- with the :djadmin:`django-admin.py makemessages <makemessages>` tool.
|
||||
files -- with the :djadmin:`django-admin makemessages <makemessages>` tool.
|
||||
The only difference is you need to explicitly specify what in gettext parlance
|
||||
is known as a domain in this case the ``djangojs`` domain, by providing a ``-d
|
||||
djangojs`` parameter, like this::
|
||||
|
||||
django-admin.py makemessages -d djangojs -l de
|
||||
django-admin makemessages -d djangojs -l de
|
||||
|
||||
This would create or update the message file for JavaScript for German. After
|
||||
updating message files, just run :djadmin:`django-admin.py compilemessages
|
||||
updating message files, just run :djadmin:`django-admin compilemessages
|
||||
<compilemessages>` the same way as you do with normal Django message files.
|
||||
|
||||
.. _gettext_on_windows:
|
||||
@@ -1798,10 +1799,10 @@ All message file repositories are structured the same way. They are:
|
||||
* ``$APPPATH/locale/<language>/LC_MESSAGES/django.(po|mo)``
|
||||
* ``$PYTHONPATH/django/conf/locale/<language>/LC_MESSAGES/django.(po|mo)``
|
||||
|
||||
To create message files, you use the :djadmin:`django-admin.py makemessages <makemessages>`
|
||||
tool. And you use :djadmin:`django-admin.py compilemessages <compilemessages>`
|
||||
To create message files, you use the :djadmin:`django-admin makemessages <makemessages>`
|
||||
tool. And you use :djadmin:`django-admin compilemessages <compilemessages>`
|
||||
to produce the binary ``.mo`` files that are used by ``gettext``.
|
||||
|
||||
You can also run :djadmin:`django-admin.py compilemessages
|
||||
You can also run :djadmin:`django-admin compilemessages
|
||||
--settings=path.to.settings <compilemessages>` to make the compiler process all
|
||||
the directories in your :setting:`LOCALE_PATHS` setting.
|
||||
|
||||
@@ -284,7 +284,7 @@ latest bug fixes and improvements, follow these instructions:
|
||||
(If using a virtualenv_ you can omit ``sudo``.)
|
||||
|
||||
This will make Django's code importable, and will also make the
|
||||
``django-admin.py`` utility command available. In other words, you're all
|
||||
``django-admin`` utility command available. In other words, you're all
|
||||
set!
|
||||
|
||||
If you don't have pip_ available, see the alternative instructions for
|
||||
@@ -343,7 +343,7 @@ Next you need to make the ``django-admin.py`` utility available in your
|
||||
shell PATH.
|
||||
|
||||
On Unix-like systems, create a symbolic link to the file
|
||||
``django-trunk/django/bin/django-admin.py`` in a directory on your system
|
||||
``django-trunk/django/bin/django-admin`` in a directory on your system
|
||||
path, such as ``/usr/local/bin``. For example:
|
||||
|
||||
.. code-block:: bash
|
||||
@@ -359,3 +359,7 @@ rather than having to qualify the command with the full path to the file.
|
||||
On Windows systems, the same result can be achieved by copying the file
|
||||
``django-trunk/django/bin/django-admin.py`` to somewhere on your system
|
||||
path, for example ``C:\Python27\Scripts``.
|
||||
|
||||
Note that the rest of the documentation assumes this utility is installed
|
||||
as ``django-admin``. You'll have to substitute ``django-admin.py`` if you use
|
||||
this method.
|
||||
|
||||
@@ -48,28 +48,28 @@ Python `import search path`_.
|
||||
|
||||
.. _import search path: http://www.diveintopython.net/getting_to_know_python/everything_is_an_object.html
|
||||
|
||||
The django-admin.py utility
|
||||
The django-admin utility
|
||||
---------------------------
|
||||
|
||||
When using :doc:`django-admin.py </ref/django-admin>`, you can either set the
|
||||
When using :doc:`django-admin </ref/django-admin>`, you can either set the
|
||||
environment variable once, or explicitly pass in the settings module each time
|
||||
you run the utility.
|
||||
|
||||
Example (Unix Bash shell)::
|
||||
|
||||
export DJANGO_SETTINGS_MODULE=mysite.settings
|
||||
django-admin.py runserver
|
||||
django-admin runserver
|
||||
|
||||
Example (Windows shell)::
|
||||
|
||||
set DJANGO_SETTINGS_MODULE=mysite.settings
|
||||
django-admin.py runserver
|
||||
django-admin runserver
|
||||
|
||||
Use the ``--settings`` command-line argument to specify the settings manually::
|
||||
|
||||
django-admin.py runserver --settings=mysite.settings
|
||||
django-admin runserver --settings=mysite.settings
|
||||
|
||||
.. _django-admin.py: ../django-admin/
|
||||
.. _django-admin: ../django-admin/
|
||||
|
||||
On the server (mod_wsgi)
|
||||
--------------------------
|
||||
|
||||
Reference in New Issue
Block a user