Fixed #23067 -- Updated docs to use django-admin
This commit is contained in:
parent
66630f589c
commit
d47409831f
|
@ -114,7 +114,7 @@ def call_command(name, *args, **options):
|
|||
|
||||
class ManagementUtility(object):
|
||||
"""
|
||||
Encapsulates the logic of the django-admin.py and manage.py utilities.
|
||||
Encapsulates the logic of the django-admin and manage.py utilities.
|
||||
|
||||
A ManagementUtility has a number of commands, which can be manipulated
|
||||
by editing the self.commands dictionary.
|
||||
|
@ -163,7 +163,7 @@ class ManagementUtility(object):
|
|||
"""
|
||||
Tries to fetch the given subcommand, printing a message with the
|
||||
appropriate command called from the command line (usually
|
||||
"django-admin.py" or "manage.py") if it can't be found.
|
||||
"django-admin" or "manage.py") if it can't be found.
|
||||
"""
|
||||
# Get commands outside of try block to prevent swallowing exceptions
|
||||
commands = get_commands()
|
||||
|
@ -312,8 +312,8 @@ class ManagementUtility(object):
|
|||
sys.stdout.write(self.main_help_text() + '\n')
|
||||
else:
|
||||
self.fetch_command(options.args[0]).print_help(self.prog_name, options.args[0])
|
||||
# Special-cases: We want 'django-admin.py --version' and
|
||||
# 'django-admin.py --help' to work, for backwards compatibility.
|
||||
# Special-cases: We want 'django-admin --version' and
|
||||
# 'django-admin --help' to work, for backwards compatibility.
|
||||
elif subcommand == 'version' or self.argv[1:] == ['--version']:
|
||||
sys.stdout.write(django.get_version() + '\n')
|
||||
elif self.argv[1:] in (['--help'], ['-h']):
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
|||
|
||||
"""
|
||||
Base classes for writing management commands (named commands which can
|
||||
be executed through ``django-admin.py`` or ``manage.py``).
|
||||
be executed through ``django-admin`` or ``manage.py``).
|
||||
"""
|
||||
|
||||
import os
|
||||
|
@ -112,7 +112,7 @@ class BaseCommand(object):
|
|||
the command-parsing and -execution behavior, the normal flow works
|
||||
as follows:
|
||||
|
||||
1. ``django-admin.py`` or ``manage.py`` loads the command class
|
||||
1. ``django-admin`` or ``manage.py`` loads the command class
|
||||
and calls its ``run_from_argv()`` method.
|
||||
|
||||
2. The ``run_from_argv()`` method calls ``create_parser()`` to get
|
||||
|
@ -398,7 +398,7 @@ class BaseCommand(object):
|
|||
"(%s) and 'can_import_settings' (%s) command "
|
||||
"options." % (self.leave_locale_alone,
|
||||
self.can_import_settings))
|
||||
# Switch to US English, because django-admin.py creates database
|
||||
# Switch to US English, because django-admin creates database
|
||||
# content like permissions, and those shouldn't contain any
|
||||
# translations.
|
||||
from django.utils import translation
|
||||
|
|
|
@ -73,7 +73,7 @@ Are you sure you want to do this?
|
|||
" * The database isn't running or isn't configured correctly.\n"
|
||||
" * At least one of the expected database tables doesn't exist.\n"
|
||||
" * The SQL was invalid.\n"
|
||||
"Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.\n"
|
||||
"Hint: Look at the output of 'django-admin sqlflush'. That's the SQL this command wasn't able to run.\n"
|
||||
"The full error: %s") % (connection.settings_dict['NAME'], e)
|
||||
six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2])
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class Command(BaseCommand):
|
|||
yield "# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table"
|
||||
yield "# Feel free to rename the models, but don't rename db_table values or field names."
|
||||
yield "#"
|
||||
yield "# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [app_label]'"
|
||||
yield "# Also note: You'll have to insert the output of 'django-admin sqlcustom [app_label]'"
|
||||
yield "# into your database."
|
||||
yield "from __future__ import unicode_literals"
|
||||
yield ''
|
||||
|
|
|
@ -300,7 +300,7 @@ class DjangoHTMLTranslator(SmartyPantsHTMLTranslator):
|
|||
def parse_django_admin_node(env, sig, signode):
|
||||
command = sig.split(' ')[0]
|
||||
env._django_curr_admin_command = command
|
||||
title = "django-admin.py %s" % sig
|
||||
title = "django-admin %s" % sig
|
||||
signode += addnodes.desc_name(title, title)
|
||||
return sig
|
||||
|
||||
|
|
|
@ -5,50 +5,34 @@ Troubleshooting
|
|||
This page contains some advice about errors and problems commonly encountered
|
||||
during the development of Django applications.
|
||||
|
||||
.. _troubleshooting-django-admin-py:
|
||||
.. _troubleshooting-django-admin:
|
||||
|
||||
Problems running django-admin.py
|
||||
================================
|
||||
Problems running django-admin
|
||||
=============================
|
||||
|
||||
"command not found: django-admin.py"
|
||||
"command not found: django-admin"
|
||||
------------------------------------
|
||||
|
||||
:doc:`django-admin.py </ref/django-admin>` should be on your system path if you
|
||||
:doc:`django-admin </ref/django-admin>` should be on your system path if you
|
||||
installed Django via ``python setup.py``. If it's not on your path, you can
|
||||
find it in ``site-packages/django/bin``, where ``site-packages`` is a directory
|
||||
within your Python installation. Consider symlinking to :doc:`django-admin.py
|
||||
within your Python installation. Consider symlinking to :doc:`django-admin
|
||||
</ref/django-admin>` from some place on your path, such as
|
||||
:file:`/usr/local/bin`.
|
||||
|
||||
Script name may differ in distribution packages
|
||||
-----------------------------------------------
|
||||
|
||||
If you installed Django using a Linux distribution's package manager
|
||||
(e.g. ``apt-get`` or ``yum``) ``django-admin.py`` may have been renamed to
|
||||
``django-admin``; use that instead.
|
||||
If ``django-admin`` doesn't work but ``django-admin.py`` does, you're probably
|
||||
using a version of Django that doesn't match the version of this documentation.
|
||||
``django-admin`` is new in Django 1.7.
|
||||
|
||||
Mac OS X permissions
|
||||
--------------------
|
||||
|
||||
If you're using Mac OS X, you may see the message "permission denied" when
|
||||
you try to run ``django-admin.py``. This is because, on Unix-based systems like
|
||||
you try to run ``django-admin``. This is because, on Unix-based systems like
|
||||
OS X, a file must be marked as "executable" before it can be run as a program.
|
||||
To do this, open Terminal.app and navigate (using the ``cd`` command) to the
|
||||
directory where :doc:`django-admin.py </ref/django-admin>` is installed, then
|
||||
run the command ``sudo chmod +x django-admin.py``.
|
||||
|
||||
Running virtualenv on Windows
|
||||
-----------------------------
|
||||
|
||||
If you used virtualenv_ to :ref:`install Django <installing-official-release>`
|
||||
on Windows, you may get an ``ImportError`` when you try to run
|
||||
``django-admin.py``. This is because Windows does not run the
|
||||
Python interpreter from your virtual environment unless you invoke it
|
||||
directly. Instead, prefix all commands that use .py files with ``python`` and
|
||||
use the full path to the file, like so:
|
||||
``python C:\pythonXY\Scripts\django-admin.py``.
|
||||
|
||||
.. _virtualenv: http://www.virtualenv.org/
|
||||
directory where :doc:`django-admin </ref/django-admin>` is installed, then
|
||||
run the command ``sudo chmod +x django-admin``.
|
||||
|
||||
Miscellaneous
|
||||
=============
|
||||
|
|
|
@ -55,7 +55,7 @@ The ``WSGIAuthUserScript`` directive tells mod_wsgi to execute the
|
|||
``check_password`` function in specified wsgi script, passing the user name and
|
||||
password that it receives from the prompt. In this example, the
|
||||
``WSGIAuthUserScript`` is the same as the ``WSGIScriptAlias`` that defines your
|
||||
application :doc:`that is created by django-admin.py startproject
|
||||
application :doc:`that is created by django-admin startproject
|
||||
</howto/deployment/wsgi/index>`.
|
||||
|
||||
.. admonition:: Using Apache 2.2 with authentication
|
||||
|
|
|
@ -78,7 +78,7 @@ Here's an example command to start a uWSGI server::
|
|||
|
||||
This assumes you have a top-level project package named ``mysite``, and
|
||||
within it a module :file:`mysite/wsgi.py` that contains a WSGI ``application``
|
||||
object. This is the layout you'll have if you ran ``django-admin.py
|
||||
object. This is the layout you'll have if you ran ``django-admin
|
||||
startproject mysite`` (using your own project name in place of ``mysite``) with
|
||||
a recent version of Django. If this file doesn't exist, you'll need to create
|
||||
it. See the :doc:`/howto/deployment/wsgi/index` documentation for the default
|
||||
|
|
|
@ -60,7 +60,7 @@ In the command prompt, execute the following command: ``pip install django``.
|
|||
This will download and install Django.
|
||||
|
||||
After the installation has completed, you can verify your Django installation
|
||||
by executing ``django-admin.py --version`` in the command prompt.
|
||||
by executing ``django-admin --version`` in the command prompt.
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
|
||||
|
@ -73,7 +73,7 @@ with Django.
|
|||
Common pitfalls
|
||||
===============
|
||||
|
||||
* If ``django-admin.py`` only displays the help text no matter what arguments
|
||||
* If ``django-admin`` only displays the help text no matter what arguments
|
||||
it is given, there is probably a problem with the file association in
|
||||
Windows. Check if there is more than one environment variable set for
|
||||
running Python scripts in ``PATH``. This usually occurs when there is more
|
||||
|
@ -86,7 +86,3 @@ Common pitfalls
|
|||
|
||||
set http_proxy=http://username:password@proxyserver:proxyport
|
||||
set https_proxy=https://username:password@proxyserver:proxyport
|
||||
|
||||
* Executing ``django-admin.py`` opens up a text file. This is due to the text
|
||||
editor being the default program for ``.py`` files. This must be changed
|
||||
to the ``python.exe`` located in the folder where Python is installed.
|
||||
|
|
|
@ -191,7 +191,7 @@ testing of Django applications:
|
|||
* **Exceptions:**
|
||||
:doc:`Overview <ref/exceptions>`
|
||||
|
||||
* **django-admin.py and manage.py:**
|
||||
* **django-admin and manage.py:**
|
||||
:doc:`Overview <ref/django-admin>` |
|
||||
:doc:`Adding custom commands <howto/custom-management-commands>`
|
||||
|
||||
|
|
|
@ -53,10 +53,10 @@ code, then run the following command:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ django-admin.py startproject mysite
|
||||
$ django-admin startproject mysite
|
||||
|
||||
This will create a ``mysite`` directory in your current directory. If it didn't
|
||||
work, see :ref:`troubleshooting-django-admin-py`.
|
||||
work, see :ref:`troubleshooting-django-admin`.
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -577,7 +577,7 @@ you'll commit migrations to your version control system and ship them with
|
|||
your app; they not only make your development easier, they're also useable by
|
||||
other developers and in production.
|
||||
|
||||
Read the :doc:`django-admin.py documentation </ref/django-admin>` for full
|
||||
Read the :doc:`django-admin documentation </ref/django-admin>` for full
|
||||
information on what the ``manage.py`` utility can do.
|
||||
|
||||
Playing with the API
|
||||
|
@ -611,7 +611,7 @@ the Python import path to your :file:`mysite/settings.py` file.
|
|||
or ensure that directory is on the Python path, so that ``import mysite``
|
||||
works.
|
||||
|
||||
For more information on all of this, see the :doc:`django-admin.py
|
||||
For more information on all of this, see the :doc:`django-admin
|
||||
documentation </ref/django-admin>`.
|
||||
|
||||
Once you're in the shell, explore the :doc:`database API </topics/db/queries>`::
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.TH "django-admin.py" "1" "March 2008" "Django Project" ""
|
||||
.TH "django-admin" "1" "March 2008" "Django Project" ""
|
||||
.SH "NAME"
|
||||
django\-admin.py \- Utility script for the Django Web framework
|
||||
.SH "SYNOPSIS"
|
||||
|
@ -166,8 +166,8 @@ Enables IPv6 addresses.
|
|||
Verbosity level: 0=minimal output, 1=normal output, 2=all output.
|
||||
.TP
|
||||
.I \-\-traceback
|
||||
By default, django-admin.py will show a simple error message whenever an
|
||||
error occurs. If you specify this option, django-admin.py will
|
||||
By default, django-admin will show a simple error message whenever an
|
||||
error occurs. If you specify this option, django-admin will
|
||||
output a full stack trace whenever an exception is raised.
|
||||
.TP
|
||||
.I \-l, \-\-locale=LOCALE
|
||||
|
@ -235,4 +235,3 @@ AUTHORS file in the Django distribution for contributors.
|
|||
.SH "LICENSE"
|
||||
New BSD license. For the full license text refer to the LICENSE file in the
|
||||
Django distribution.
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ Installing the contenttypes framework
|
|||
=====================================
|
||||
|
||||
The contenttypes framework is included in the default
|
||||
:setting:`INSTALLED_APPS` list created by ``django-admin.py startproject``,
|
||||
:setting:`INSTALLED_APPS` list created by ``django-admin startproject``,
|
||||
but if you've removed it or if you manually set up your
|
||||
:setting:`INSTALLED_APPS` list, you can enable it by adding
|
||||
``'django.contrib.contenttypes'`` to your :setting:`INSTALLED_APPS` setting.
|
||||
|
|
|
@ -7,7 +7,7 @@ GeoDjango Management Commands
|
|||
inspectdb
|
||||
=========
|
||||
|
||||
.. describe:: django-admin.py inspectdb
|
||||
.. describe:: django-admin inspectdb
|
||||
|
||||
When :mod:`django.contrib.gis` is in your :setting:`INSTALLED_APPS`, the
|
||||
:djadmin:`inspectdb` management command is overridden with one from GeoDjango.
|
||||
|
|
|
@ -81,12 +81,12 @@ to create a :ref:`SpatiaLite database <create_spatialite_db>`.
|
|||
Create a New Project
|
||||
------------------------
|
||||
|
||||
Use the standard ``django-admin.py`` script to create a project called
|
||||
Use the standard ``django-admin`` script to create a project called
|
||||
``geodjango``:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ django-admin.py startproject geodjango
|
||||
$ django-admin startproject geodjango
|
||||
|
||||
This will initialize a new project. Now, create a ``world`` Django application
|
||||
within the ``geodjango`` project:
|
||||
|
|
|
@ -22,7 +22,7 @@ Enabling messages
|
|||
Messages are implemented through a :doc:`middleware </ref/middleware>`
|
||||
class and corresponding :doc:`context processor </ref/templates/api>`.
|
||||
|
||||
The default ``settings.py`` created by ``django-admin.py startproject``
|
||||
The default ``settings.py`` created by ``django-admin startproject``
|
||||
already contains all the settings required to enable message functionality:
|
||||
|
||||
* ``'django.contrib.messages'`` is in :setting:`INSTALLED_APPS`.
|
||||
|
|
|
@ -198,7 +198,7 @@ in your project's :setting:`INSTALLED_APPS` setting.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py runserver --nostatic
|
||||
django-admin runserver --nostatic
|
||||
|
||||
.. django-admin-option:: --insecure
|
||||
|
||||
|
@ -214,7 +214,7 @@ in your project's :setting:`INSTALLED_APPS` setting. :djadmin:`runserver`
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py runserver --insecure
|
||||
django-admin runserver --insecure
|
||||
|
||||
.. _staticfiles-storages:
|
||||
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
=============================
|
||||
django-admin.py and manage.py
|
||||
=============================
|
||||
==========================
|
||||
django-admin and manage.py
|
||||
==========================
|
||||
|
||||
``django-admin.py`` is Django's command-line utility for administrative tasks.
|
||||
``django-admin`` is Django's command-line utility for administrative tasks.
|
||||
This document outlines all it can do.
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
|
||||
Prior to Django 1.7, ``django-admin`` was only installed as
|
||||
``django-admin.py``.
|
||||
|
||||
In addition, ``manage.py`` is automatically created in each Django project.
|
||||
``manage.py`` is a thin wrapper around ``django-admin.py`` that takes care of
|
||||
two things for you before delegating to ``django-admin.py``:
|
||||
``manage.py`` is a thin wrapper around ``django-admin`` that takes care of
|
||||
two things for you before delegating to ``django-admin``:
|
||||
|
||||
* It puts your project's package on ``sys.path``.
|
||||
|
||||
|
@ -20,23 +25,23 @@ two things for you before delegating to ``django-admin.py``:
|
|||
|
||||
:func:`django.setup()` didn't exist in previous versions of Django.
|
||||
|
||||
The ``django-admin.py`` script should be on your system path if you installed
|
||||
The ``django-admin`` script should be on your system path if you installed
|
||||
Django via its ``setup.py`` utility. If it's not on your path, you can find it
|
||||
in ``site-packages/django/bin`` within your Python installation. Consider
|
||||
symlinking it from some place on your path, such as ``/usr/local/bin``.
|
||||
|
||||
For Windows users, who do not have symlinking functionality available, you can
|
||||
copy ``django-admin.py`` to a location on your existing path or edit the
|
||||
copy ``django-admin.exe`` to a location on your existing path or edit the
|
||||
``PATH`` settings (under ``Settings - Control Panel - System - Advanced -
|
||||
Environment...``) to point to its installed location.
|
||||
|
||||
Generally, when working on a single Django project, it's easier to use
|
||||
``manage.py`` than ``django-admin.py``. If you need to switch between multiple
|
||||
Django settings files, use ``django-admin.py`` with
|
||||
``manage.py`` than ``django-admin``. If you need to switch between multiple
|
||||
Django settings files, use ``django-admin`` with
|
||||
:envvar:`DJANGO_SETTINGS_MODULE` or the :djadminopt:`--settings` command line
|
||||
option.
|
||||
|
||||
The command-line examples throughout this document use ``django-admin.py`` to
|
||||
The command-line examples throughout this document use ``django-admin`` to
|
||||
be consistent, but any example can use ``manage.py`` just as well.
|
||||
|
||||
Usage
|
||||
|
@ -44,7 +49,7 @@ Usage
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ django-admin.py <command> [options]
|
||||
$ django-admin <command> [options]
|
||||
$ manage.py <command> [options]
|
||||
|
||||
``command`` should be one of the commands listed in this document.
|
||||
|
@ -56,13 +61,13 @@ Getting runtime help
|
|||
|
||||
.. django-admin:: help
|
||||
|
||||
Run ``django-admin.py help`` to display usage information and a list of the
|
||||
Run ``django-admin help`` to display usage information and a list of the
|
||||
commands provided by each application.
|
||||
|
||||
Run ``django-admin.py help --commands`` to display a list of all available
|
||||
Run ``django-admin help --commands`` to display a list of all available
|
||||
commands.
|
||||
|
||||
Run ``django-admin.py help <command>`` to display a description of the given
|
||||
Run ``django-admin help <command>`` to display a description of the given
|
||||
command and a list of its available options.
|
||||
|
||||
App names
|
||||
|
@ -77,7 +82,7 @@ Determining the version
|
|||
|
||||
.. django-admin:: version
|
||||
|
||||
Run ``django-admin.py version`` to display the current Django version.
|
||||
Run ``django-admin version`` to display the current Django version.
|
||||
|
||||
The output follows the schema described in :pep:`386`::
|
||||
|
||||
|
@ -89,7 +94,7 @@ Displaying debug output
|
|||
-----------------------
|
||||
|
||||
Use :djadminopt:`--verbosity` to specify the amount of notification and debug information
|
||||
that ``django-admin.py`` should print to the console. For more details, see the
|
||||
that ``django-admin`` should print to the console. For more details, see the
|
||||
documentation for the :djadminopt:`--verbosity` option.
|
||||
|
||||
Available commands
|
||||
|
@ -149,14 +154,14 @@ are excluded.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py compilemessages --locale=pt_BR
|
||||
django-admin.py compilemessages --locale=pt_BR --locale=fr
|
||||
django-admin.py compilemessages -l pt_BR
|
||||
django-admin.py compilemessages -l pt_BR -l fr
|
||||
django-admin.py compilemessages --exclude=pt_BR
|
||||
django-admin.py compilemessages --exclude=pt_BR --exclude=fr
|
||||
django-admin.py compilemessages -x pt_BR
|
||||
django-admin.py compilemessages -x pt_BR -x fr
|
||||
django-admin compilemessages --locale=pt_BR
|
||||
django-admin compilemessages --locale=pt_BR --locale=fr
|
||||
django-admin compilemessages -l pt_BR
|
||||
django-admin compilemessages -l pt_BR -l fr
|
||||
django-admin compilemessages --exclude=pt_BR
|
||||
django-admin compilemessages --exclude=pt_BR --exclude=fr
|
||||
django-admin compilemessages -x pt_BR
|
||||
django-admin compilemessages -x pt_BR -x fr
|
||||
|
||||
createcachetable
|
||||
----------------
|
||||
|
@ -418,7 +423,7 @@ the provided fixture names.
|
|||
If the named fixture has a file extension, only fixtures of that type
|
||||
will be loaded. For example::
|
||||
|
||||
django-admin.py loaddata mydata.json
|
||||
django-admin loaddata mydata.json
|
||||
|
||||
would only load JSON fixtures called ``mydata``. The fixture extension
|
||||
must correspond to the registered name of a
|
||||
|
@ -427,7 +432,7 @@ must correspond to the registered name of a
|
|||
If you omit the extensions, Django will search all available fixture types
|
||||
for a matching fixture. For example::
|
||||
|
||||
django-admin.py loaddata mydata
|
||||
django-admin loaddata mydata
|
||||
|
||||
would look for any fixture of any fixture type called ``mydata``. If a fixture
|
||||
directory contained ``mydata.json``, that fixture would be loaded
|
||||
|
@ -436,7 +441,7 @@ as a JSON fixture.
|
|||
The fixtures that are named can include directory components. These
|
||||
directories will be included in the search path. For example::
|
||||
|
||||
django-admin.py loaddata foo/bar/mydata.json
|
||||
django-admin loaddata foo/bar/mydata.json
|
||||
|
||||
would search ``<app_label>/fixtures/foo/bar/mydata.json`` for each installed
|
||||
application, ``<dirname>/foo/bar/mydata.json`` for each directory in
|
||||
|
@ -497,7 +502,7 @@ Compressed fixtures
|
|||
|
||||
Fixtures may be compressed in ``zip``, ``gz``, or ``bz2`` format. For example::
|
||||
|
||||
django-admin.py loaddata mydata.json
|
||||
django-admin loaddata mydata.json
|
||||
|
||||
would look for any of ``mydata.json``, ``mydata.json.zip``,
|
||||
``mydata.json.gz``, or ``mydata.json.bz2``. The first file contained within a
|
||||
|
@ -546,7 +551,7 @@ available languages.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py makemessages --all
|
||||
django-admin makemessages --all
|
||||
|
||||
.. django-admin-option:: --extension
|
||||
|
||||
|
@ -555,11 +560,11 @@ to examine (default: ".html", ".txt").
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py makemessages --locale=de --extension xhtml
|
||||
django-admin makemessages --locale=de --extension xhtml
|
||||
|
||||
Separate multiple extensions with commas or use -e or --extension multiple times::
|
||||
|
||||
django-admin.py makemessages --locale=de --extension=html,txt --extension xml
|
||||
django-admin makemessages --locale=de --extension=html,txt --extension xml
|
||||
|
||||
Use the :djadminopt:`--locale` option (or its shorter version ``-l``) to
|
||||
specify the locale(s) to process.
|
||||
|
@ -572,14 +577,14 @@ are excluded.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py makemessages --locale=pt_BR
|
||||
django-admin.py makemessages --locale=pt_BR --locale=fr
|
||||
django-admin.py makemessages -l pt_BR
|
||||
django-admin.py makemessages -l pt_BR -l fr
|
||||
django-admin.py makemessages --exclude=pt_BR
|
||||
django-admin.py makemessages --exclude=pt_BR --exclude=fr
|
||||
django-admin.py makemessages -x pt_BR
|
||||
django-admin.py makemessages -x pt_BR -x fr
|
||||
django-admin makemessages --locale=pt_BR
|
||||
django-admin makemessages --locale=pt_BR --locale=fr
|
||||
django-admin makemessages -l pt_BR
|
||||
django-admin makemessages -l pt_BR -l fr
|
||||
django-admin makemessages --exclude=pt_BR
|
||||
django-admin makemessages --exclude=pt_BR --exclude=fr
|
||||
django-admin makemessages -x pt_BR
|
||||
django-admin makemessages -x pt_BR -x fr
|
||||
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
|
@ -602,7 +607,7 @@ looking for new translation strings.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py makemessages --locale=de --symlinks
|
||||
django-admin makemessages --locale=de --symlinks
|
||||
|
||||
.. django-admin-option:: --ignore
|
||||
|
||||
|
@ -613,7 +618,7 @@ These patterns are used by default: ``'CVS'``, ``'.*'``, ``'*~'``, ``'*.pyc'``
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py makemessages --locale=en_US --ignore=apps/* --ignore=secret/*.html
|
||||
django-admin makemessages --locale=en_US --ignore=apps/* --ignore=secret/*.html
|
||||
|
||||
.. django-admin-option:: --no-default-ignore
|
||||
|
||||
|
@ -844,7 +849,7 @@ Umask to use when daemonizing. The value is interpreted as an octal number
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py runfcgi socket=/tmp/fcgi.sock method=prefork daemonize=true \
|
||||
django-admin runfcgi socket=/tmp/fcgi.sock method=prefork daemonize=true \
|
||||
pidfile=/var/run/django-fcgi.pid
|
||||
|
||||
Run a FastCGI server as a daemon and write the spawned PID in a file.
|
||||
|
@ -898,7 +903,7 @@ the :djadmin:`check` command). If any errors are found, they will be printed
|
|||
to standard output, but it won't stop the server.
|
||||
|
||||
You can run as many servers as you want, as long as they're on separate ports.
|
||||
Just execute ``django-admin.py runserver`` more than once.
|
||||
Just execute ``django-admin runserver`` more than once.
|
||||
|
||||
Note that the default IP address, ``127.0.0.1``, is not accessible from other
|
||||
machines on your network. To make your development server viewable to other
|
||||
|
@ -923,7 +928,7 @@ memory.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py runserver --noreload
|
||||
django-admin runserver --noreload
|
||||
|
||||
.. django-admin-option:: --nothreading
|
||||
|
||||
|
@ -938,46 +943,46 @@ the development server. This changes the default IP address from
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py runserver --ipv6
|
||||
django-admin runserver --ipv6
|
||||
|
||||
Examples of using different ports and addresses
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Port 8000 on IP address ``127.0.0.1``::
|
||||
|
||||
django-admin.py runserver
|
||||
django-admin runserver
|
||||
|
||||
Port 8000 on IP address ``1.2.3.4``::
|
||||
|
||||
django-admin.py runserver 1.2.3.4:8000
|
||||
django-admin runserver 1.2.3.4:8000
|
||||
|
||||
Port 7000 on IP address ``127.0.0.1``::
|
||||
|
||||
django-admin.py runserver 7000
|
||||
django-admin runserver 7000
|
||||
|
||||
Port 7000 on IP address ``1.2.3.4``::
|
||||
|
||||
django-admin.py runserver 1.2.3.4:7000
|
||||
django-admin runserver 1.2.3.4:7000
|
||||
|
||||
Port 8000 on IPv6 address ``::1``::
|
||||
|
||||
django-admin.py runserver -6
|
||||
django-admin runserver -6
|
||||
|
||||
Port 7000 on IPv6 address ``::1``::
|
||||
|
||||
django-admin.py runserver -6 7000
|
||||
django-admin runserver -6 7000
|
||||
|
||||
Port 7000 on IPv6 address ``2001:0db8:1234:5678::9``::
|
||||
|
||||
django-admin.py runserver [2001:0db8:1234:5678::9]:7000
|
||||
django-admin runserver [2001:0db8:1234:5678::9]:7000
|
||||
|
||||
Port 8000 on IPv4 address of host ``localhost``::
|
||||
|
||||
django-admin.py runserver localhost:8000
|
||||
django-admin runserver localhost:8000
|
||||
|
||||
Port 8000 on IPv6 address of host ``localhost``::
|
||||
|
||||
django-admin.py runserver -6 localhost:8000
|
||||
django-admin runserver -6 localhost:8000
|
||||
|
||||
Serving static files with the development server
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -998,7 +1003,7 @@ Django will use IPython_ or bpython_ if either is installed. If you have a
|
|||
rich shell installed but want to force use of the "plain" Python interpreter,
|
||||
use the ``--plain`` option, like so::
|
||||
|
||||
django-admin.py shell --plain
|
||||
django-admin shell --plain
|
||||
|
||||
If you would like to specify either IPython or bpython as your interpreter if
|
||||
you have both installed you can specify an alternative interpreter interface
|
||||
|
@ -1006,14 +1011,14 @@ with the ``-i`` or ``--interface`` options like so:
|
|||
|
||||
IPython::
|
||||
|
||||
django-admin.py shell -i ipython
|
||||
django-admin.py shell --interface ipython
|
||||
django-admin shell -i ipython
|
||||
django-admin shell --interface ipython
|
||||
|
||||
|
||||
bpython::
|
||||
|
||||
django-admin.py shell -i bpython
|
||||
django-admin.py shell --interface bpython
|
||||
django-admin shell -i bpython
|
||||
django-admin shell --interface bpython
|
||||
|
||||
|
||||
.. _IPython: http://ipython.scipy.org/
|
||||
|
@ -1025,7 +1030,7 @@ available) it reads the script pointed to by the :envvar:`PYTHONSTARTUP`
|
|||
environment variable and the ``~/.pythonrc.py`` script. If you don't wish this
|
||||
behavior you can use the ``--no-startup`` option. e.g.::
|
||||
|
||||
django-admin.py shell --plain --no-startup
|
||||
django-admin shell --plain --no-startup
|
||||
|
||||
sql <app_label app_label ...>
|
||||
-----------------------------
|
||||
|
@ -1194,7 +1199,7 @@ working directory.
|
|||
|
||||
For example::
|
||||
|
||||
django-admin.py startapp myapp /Users/jezdez/Code/myapp
|
||||
django-admin startapp myapp /Users/jezdez/Code/myapp
|
||||
|
||||
.. _custom-app-and-project-templates:
|
||||
|
||||
|
@ -1208,7 +1213,7 @@ containing the app template files.
|
|||
For example, this would look for an app template in the given directory when
|
||||
creating the ``myapp`` app::
|
||||
|
||||
django-admin.py startapp --template=/Users/jezdez/Code/my_app_template myapp
|
||||
django-admin startapp --template=/Users/jezdez/Code/my_app_template myapp
|
||||
|
||||
Django will also accept URLs (``http``, ``https``, ``ftp``) to compressed
|
||||
archives with the app template files, downloading and extracting them on the
|
||||
|
@ -1217,7 +1222,7 @@ fly.
|
|||
For example, taking advantage of Github's feature to expose repositories as
|
||||
zip files, you can use a URL like::
|
||||
|
||||
django-admin.py startapp --template=https://github.com/githubuser/django-app-template/archive/master.zip myapp
|
||||
django-admin startapp --template=https://github.com/githubuser/django-app-template/archive/master.zip myapp
|
||||
|
||||
When Django copies the app template files, it also renders certain files
|
||||
through the template engine: the files whose extensions match the
|
||||
|
@ -1268,7 +1273,7 @@ package within it. Use '.' to denote the current working directory.
|
|||
|
||||
For example::
|
||||
|
||||
django-admin.py startproject myproject /Users/jezdez/Code/myproject_repo
|
||||
django-admin startproject myproject /Users/jezdez/Code/myproject_repo
|
||||
|
||||
As with the :djadmin:`startapp` command, the ``--template`` option lets you
|
||||
specify a directory, file path or URL of a custom project template. See the
|
||||
|
@ -1278,7 +1283,7 @@ formats.
|
|||
For example, this would look for a project template in the given directory
|
||||
when creating the ``myproject`` project::
|
||||
|
||||
django-admin.py startproject --template=/Users/jezdez/Code/my_project_template myproject
|
||||
django-admin startproject --template=/Users/jezdez/Code/my_project_template myproject
|
||||
|
||||
Django will also accept URLs (``http``, ``https``, ``ftp``) to compressed
|
||||
archives with the project template files, downloading and extracting them on the
|
||||
|
@ -1287,7 +1292,7 @@ fly.
|
|||
For example, taking advantage of Github's feature to expose repositories as
|
||||
zip files, you can use a URL like::
|
||||
|
||||
django-admin.py startproject --template=https://github.com/githubuser/django-project-template/archive/master.zip myproject
|
||||
django-admin startproject --template=https://github.com/githubuser/django-project-template/archive/master.zip myproject
|
||||
|
||||
When Django copies the project template files, it also renders certain files
|
||||
through the template engine: the files whose extensions match the
|
||||
|
@ -1366,7 +1371,7 @@ the given fixture(s).
|
|||
|
||||
For example, this command::
|
||||
|
||||
django-admin.py testserver mydata.json
|
||||
django-admin testserver mydata.json
|
||||
|
||||
...would perform the following steps:
|
||||
|
||||
|
@ -1405,8 +1410,8 @@ Examples:
|
|||
|
||||
To run the test server on port 7000 with ``fixture1`` and ``fixture2``::
|
||||
|
||||
django-admin.py testserver --addrport 7000 fixture1 fixture2
|
||||
django-admin.py testserver fixture1 fixture2 --addrport 7000
|
||||
django-admin testserver --addrport 7000 fixture1 fixture2
|
||||
django-admin testserver fixture1 fixture2 --addrport 7000
|
||||
|
||||
(The above statements are equivalent. We include both of them to demonstrate
|
||||
that it doesn't matter whether the options come before or after the fixture
|
||||
|
@ -1414,7 +1419,7 @@ arguments.)
|
|||
|
||||
To run on 1.2.3.4:7000 with a ``test`` fixture::
|
||||
|
||||
django-admin.py testserver --addrport 1.2.3.4:7000 test
|
||||
django-admin testserver --addrport 1.2.3.4:7000 test
|
||||
|
||||
The :djadminopt:`--noinput` option may be provided to suppress all user
|
||||
prompts.
|
||||
|
@ -1459,7 +1464,7 @@ it's not supplied, Django will use the ``default`` database.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py changepassword ringo
|
||||
django-admin changepassword ringo
|
||||
|
||||
createsuperuser
|
||||
~~~~~~~~~~~~~~~
|
||||
|
@ -1564,10 +1569,10 @@ allows for the following options:
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py migrate --pythonpath='/home/djangoprojects/myproject'
|
||||
django-admin migrate --pythonpath='/home/djangoprojects/myproject'
|
||||
|
||||
Adds the given filesystem path to the Python `import search path`_. If this
|
||||
isn't provided, ``django-admin.py`` will use the ``PYTHONPATH`` environment
|
||||
isn't provided, ``django-admin`` will use the ``PYTHONPATH`` environment
|
||||
variable.
|
||||
|
||||
Note that this option is unnecessary in ``manage.py``, because it takes care of
|
||||
|
@ -1579,11 +1584,11 @@ setting the Python path for you.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py migrate --settings=mysite.settings
|
||||
django-admin migrate --settings=mysite.settings
|
||||
|
||||
Explicitly specifies the settings module to use. The settings module should be
|
||||
in Python package syntax, e.g. ``mysite.settings``. If this isn't provided,
|
||||
``django-admin.py`` will use the ``DJANGO_SETTINGS_MODULE`` environment
|
||||
``django-admin`` will use the ``DJANGO_SETTINGS_MODULE`` environment
|
||||
variable.
|
||||
|
||||
Note that this option is unnecessary in ``manage.py``, because it uses
|
||||
|
@ -1593,21 +1598,21 @@ Note that this option is unnecessary in ``manage.py``, because it uses
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py migrate --traceback
|
||||
django-admin migrate --traceback
|
||||
|
||||
By default, ``django-admin.py`` will show a simple error message whenever an
|
||||
By default, ``django-admin`` will show a simple error message whenever an
|
||||
:class:`~django.core.management.CommandError` occurs, but a full stack trace
|
||||
for any other exception. If you specify ``--traceback``, ``django-admin.py``
|
||||
for any other exception. If you specify ``--traceback``, ``django-admin``
|
||||
will also output a full stack trace when a ``CommandError`` is raised.
|
||||
|
||||
.. django-admin-option:: --verbosity
|
||||
|
||||
Example usage::
|
||||
|
||||
django-admin.py migrate --verbosity 2
|
||||
django-admin migrate --verbosity 2
|
||||
|
||||
Use ``--verbosity`` to specify the amount of notification and debug information
|
||||
that ``django-admin.py`` should print to the console.
|
||||
that ``django-admin`` should print to the console.
|
||||
|
||||
* ``0`` means no output.
|
||||
* ``1`` means normal output (default).
|
||||
|
@ -1620,9 +1625,9 @@ that ``django-admin.py`` should print to the console.
|
|||
|
||||
Example usage::
|
||||
|
||||
django-admin.py sqlall --no-color
|
||||
django-admin sqlall --no-color
|
||||
|
||||
By default, ``django-admin.py`` will format the output to be colorized. For
|
||||
By default, ``django-admin`` will format the output to be colorized. For
|
||||
example, errors will be printed to the console in red and SQL statements will
|
||||
be syntax highlighted. To prevent this and have a plain text output, pass the
|
||||
``--no-color`` option when running your command.
|
||||
|
@ -1640,7 +1645,7 @@ specified, this option will default to an alias of ``default``.
|
|||
|
||||
For example, to dump data from the database with the alias ``master``::
|
||||
|
||||
django-admin.py dumpdata --database=master
|
||||
django-admin dumpdata --database=master
|
||||
|
||||
.. django-admin-option:: --exclude
|
||||
|
||||
|
@ -1648,12 +1653,12 @@ Exclude a specific application from the applications whose contents is
|
|||
output. For example, to specifically exclude the ``auth`` application from
|
||||
the output of dumpdata, you would call::
|
||||
|
||||
django-admin.py dumpdata --exclude=auth
|
||||
django-admin dumpdata --exclude=auth
|
||||
|
||||
If you want to exclude multiple applications, use multiple ``--exclude``
|
||||
directives::
|
||||
|
||||
django-admin.py dumpdata --exclude=auth --exclude=contenttypes
|
||||
django-admin dumpdata --exclude=auth --exclude=contenttypes
|
||||
|
||||
.. django-admin-option:: --locale
|
||||
|
||||
|
@ -1663,7 +1668,7 @@ If not provided all locales are processed.
|
|||
.. django-admin-option:: --noinput
|
||||
|
||||
Use the ``--noinput`` option to suppress all user prompting, such as "Are
|
||||
you sure?" confirmation messages. This is useful if ``django-admin.py`` is
|
||||
you sure?" confirmation messages. This is useful if ``django-admin`` is
|
||||
being executed as an unattended, automated script.
|
||||
|
||||
Extra niceties
|
||||
|
@ -1674,7 +1679,7 @@ Extra niceties
|
|||
Syntax coloring
|
||||
---------------
|
||||
|
||||
The ``django-admin.py`` / ``manage.py`` commands will use pretty
|
||||
The ``django-admin`` / ``manage.py`` commands will use pretty
|
||||
color-coded output if your terminal supports ANSI-colored output. It
|
||||
won't use the color codes if you're piping the command's output to
|
||||
another program.
|
||||
|
@ -1770,7 +1775,7 @@ overridden as specified.
|
|||
|
||||
.. versionadded:: 1.7
|
||||
|
||||
Support for color-coded output from ``django-admin.py`` / ``manage.py``
|
||||
Support for color-coded output from ``django-admin`` / ``manage.py``
|
||||
utilities on Windows by relying on the ANSICON application was added in Django
|
||||
1.7.
|
||||
|
||||
|
@ -1781,10 +1786,10 @@ Bash completion
|
|||
|
||||
If you use the Bash shell, consider installing the Django bash completion
|
||||
script, which lives in ``extras/django_bash_completion`` in the Django
|
||||
distribution. It enables tab-completion of ``django-admin.py`` and
|
||||
distribution. It enables tab-completion of ``django-admin`` and
|
||||
``manage.py`` commands, so you can, for instance...
|
||||
|
||||
* Type ``django-admin.py``.
|
||||
* Type ``django-admin``.
|
||||
* Press [TAB] to see all available options.
|
||||
* Type ``sql``, then [TAB], to see all available options whose names start
|
||||
with ``sql``.
|
||||
|
|
|
@ -183,7 +183,7 @@ scenes.
|
|||
|
||||
.. attribute:: Field.db_index
|
||||
|
||||
If ``True``, :djadmin:`django-admin.py sqlindexes <sqlindexes>` will output a
|
||||
If ``True``, :djadmin:`django-admin sqlindexes <sqlindexes>` will output a
|
||||
``CREATE INDEX`` statement for this field.
|
||||
|
||||
``db_tablespace``
|
||||
|
|
|
@ -1845,7 +1845,7 @@ A secret key for a particular Django installation. This is used to provide
|
|||
:doc:`cryptographic signing </topics/signing>`, and should be set to a unique,
|
||||
unpredictable value.
|
||||
|
||||
:djadmin:`django-admin.py startproject <startproject>` automatically adds a
|
||||
:djadmin:`django-admin startproject <startproject>` automatically adds a
|
||||
randomly-generated ``SECRET_KEY`` to each new project.
|
||||
|
||||
Django will refuse to start if :setting:`SECRET_KEY` is not set.
|
||||
|
@ -2257,7 +2257,7 @@ See also :setting:`LANGUAGE_CODE`, :setting:`USE_I18N` and :setting:`USE_TZ`.
|
|||
|
||||
.. 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 ``USE_L10N = True`` for convenience.
|
||||
|
||||
.. setting:: USE_THOUSAND_SEPARATOR
|
||||
|
@ -2291,7 +2291,7 @@ See also :setting:`TIME_ZONE`, :setting:`USE_I18N` and :setting:`USE_L10N`.
|
|||
.. note::
|
||||
|
||||
The default :file:`settings.py` file created by
|
||||
:djadmin:`django-admin.py startproject <startproject>` includes
|
||||
:djadmin:`django-admin startproject <startproject>` includes
|
||||
``USE_TZ = True`` for convenience.
|
||||
|
||||
.. setting:: USE_X_FORWARDED_HOST
|
||||
|
@ -2313,7 +2313,7 @@ WSGI_APPLICATION
|
|||
Default: ``None``
|
||||
|
||||
The full Python path of the WSGI application object that Django's built-in
|
||||
servers (e.g. :djadmin:`runserver`) will use. The :djadmin:`django-admin.py
|
||||
servers (e.g. :djadmin:`runserver`) will use. The :djadmin:`django-admin
|
||||
startproject <startproject>` management command will create a simple
|
||||
``wsgi.py`` file with an ``application`` callable in it, and point this setting
|
||||
to that ``application``.
|
||||
|
|
|
@ -686,7 +686,7 @@ Internationalization
|
|||
Management Commands
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
* The :djadminopt:`--no-color` option for ``django-admin.py`` allows you to
|
||||
* The :djadminopt:`--no-color` option for ``django-admin`` allows you to
|
||||
disable the colorization of management command output.
|
||||
|
||||
* The new :djadminopt:`--natural-foreign` and :djadminopt:`--natural-primary`
|
||||
|
|
|
@ -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)
|
||||
--------------------------
|
||||
|
|
|
@ -46,7 +46,7 @@ class BashCompletionTests(unittest.TestCase):
|
|||
|
||||
def test_django_admin_py(self):
|
||||
"django_admin.py will autocomplete option flags"
|
||||
self._user_input('django-admin.py sqlall --verb')
|
||||
self._user_input('django-admin sqlall --verb')
|
||||
output = self._run_autocomplete()
|
||||
self.assertEqual(output, ['--verbosity='])
|
||||
|
||||
|
@ -58,31 +58,31 @@ class BashCompletionTests(unittest.TestCase):
|
|||
|
||||
def test_custom_command(self):
|
||||
"A custom command can autocomplete option flags"
|
||||
self._user_input('django-admin.py test_command --l')
|
||||
self._user_input('django-admin test_command --l')
|
||||
output = self._run_autocomplete()
|
||||
self.assertEqual(output, ['--list'])
|
||||
|
||||
def test_subcommands(self):
|
||||
"Subcommands can be autocompleted"
|
||||
self._user_input('django-admin.py sql')
|
||||
self._user_input('django-admin sql')
|
||||
output = self._run_autocomplete()
|
||||
self.assertEqual(output, ['sql sqlall sqlclear sqlcustom sqldropindexes sqlflush sqlindexes sqlmigrate sqlsequencereset'])
|
||||
|
||||
def test_help(self):
|
||||
"No errors, just an empty list if there are no autocomplete options"
|
||||
self._user_input('django-admin.py help --')
|
||||
self._user_input('django-admin help --')
|
||||
output = self._run_autocomplete()
|
||||
self.assertEqual(output, [''])
|
||||
|
||||
def test_runfcgi(self):
|
||||
"Command arguments will be autocompleted"
|
||||
self._user_input('django-admin.py runfcgi h')
|
||||
self._user_input('django-admin runfcgi h')
|
||||
output = self._run_autocomplete()
|
||||
self.assertEqual(output, ['host='])
|
||||
|
||||
def test_app_completion(self):
|
||||
"Application names will be autocompleted for an AppCommand"
|
||||
self._user_input('django-admin.py sqlall a')
|
||||
self._user_input('django-admin sqlall a')
|
||||
output = self._run_autocomplete()
|
||||
a_labels = sorted(app_config.label
|
||||
for app_config in apps.get_app_configs()
|
||||
|
|
Loading…
Reference in New Issue