[1.8.x] Fixed #24358 -- Corrected code-block directives for console sessions.

Backport of eba6dff581 from master
This commit is contained in:
Sean Wang 2015-02-18 19:19:21 -08:00 committed by Tim Graham
parent 1feeefe918
commit f0780df608
14 changed files with 65 additions and 65 deletions

View File

@ -24,7 +24,7 @@ The uWSGI wiki describes several `installation procedures`_. Using pip, the
Python package manager, you can install any uWSGI version with a single Python package manager, you can install any uWSGI version with a single
command. For example: command. For example:
.. code-block:: bash .. code-block:: console
# Install current stable version. # Install current stable version.
$ pip install uwsgi $ pip install uwsgi

View File

@ -24,7 +24,7 @@ The ReportLab library is `available on PyPI`_. A `user guide`_ (not
coincidentally, a PDF file) is also available for download. coincidentally, a PDF file) is also available for download.
You can install ReportLab with ``pip``: You can install ReportLab with ``pip``:
.. code-block:: bash .. code-block:: console
$ pip install reportlab $ pip install reportlab

View File

@ -52,7 +52,7 @@ might want to set up a new environment with all the dependencies first.
Exactly which steps you will need to take depends on your installation process. Exactly which steps you will need to take depends on your installation process.
The most convenient way is to use pip_ with the ``--upgrade`` or ``-U`` flag: The most convenient way is to use pip_ with the ``--upgrade`` or ``-U`` flag:
.. code-block:: bash .. code-block:: console
$ pip install -U Django $ pip install -U Django
@ -74,7 +74,7 @@ warnings are silenced by default. It is useful to turn the warnings on so they
are shown in the test output (you can also use the flag if you test your app are shown in the test output (you can also use the flag if you test your app
manually using ``manage.py runserver``): manually using ``manage.py runserver``):
.. code-block:: bash .. code-block:: console
$ python -Wall manage.py test $ python -Wall manage.py test

View File

@ -51,7 +51,7 @@ Install it
Next, run the Django command-line utility to create the database tables Next, run the Django command-line utility to create the database tables
automatically: automatically:
.. code-block:: bash .. code-block:: console
$ python manage.py migrate $ python manage.py migrate

View File

@ -15,7 +15,7 @@ It'll consist of two parts:
We'll assume you have :doc:`Django installed </intro/install>` already. You can We'll assume you have :doc:`Django installed </intro/install>` already. You can
tell Django is installed and which version by running the following command: tell Django is installed and which version by running the following command:
.. code-block:: bash .. code-block:: console
$ python -c "import django; print(django.get_version())" $ python -c "import django; print(django.get_version())"
@ -51,7 +51,7 @@ application-specific settings.
From the command line, ``cd`` into a directory where you'd like to store your From the command line, ``cd`` into a directory where you'd like to store your
code, then run the following command: code, then run the following command:
.. code-block:: bash .. code-block:: console
$ django-admin startproject mysite $ django-admin startproject mysite
@ -190,7 +190,7 @@ Some of these applications makes use of at least one database table, though,
so we need to create the tables in the database before we can use them. To do so we need to create the tables in the database before we can use them. To do
that, run the following command: that, run the following command:
.. code-block:: bash .. code-block:: console
$ python manage.py migrate $ python manage.py migrate
@ -217,7 +217,7 @@ The development server
Let's verify your Django project works. Change into the outer :file:`mysite` directory, if Let's verify your Django project works. Change into the outer :file:`mysite` directory, if
you haven't already, and run the following commands: you haven't already, and run the following commands:
.. code-block:: bash .. code-block:: console
$ python manage.py runserver $ python manage.py runserver
@ -255,7 +255,7 @@ It worked!
it as a command-line argument. For instance, this command starts the server it as a command-line argument. For instance, this command starts the server
on port 8080: on port 8080:
.. code-block:: bash .. code-block:: console
$ python manage.py runserver 8080 $ python manage.py runserver 8080
@ -263,7 +263,7 @@ It worked!
listen on all public IPs (useful if you want to show off your work on other listen on all public IPs (useful if you want to show off your work on other
computers), use: computers), use:
.. code-block:: bash .. code-block:: console
$ python manage.py runserver 0.0.0.0:8000 $ python manage.py runserver 0.0.0.0:8000
@ -305,7 +305,7 @@ imported as its own top-level module, rather than a submodule of ``mysite``.
To create your app, make sure you're in the same directory as :file:`manage.py` To create your app, make sure you're in the same directory as :file:`manage.py`
and type this command: and type this command:
.. code-block:: bash .. code-block:: console
$ python manage.py startapp polls $ python manage.py startapp polls
@ -434,7 +434,7 @@ look like this:
Now Django knows to include the ``polls`` app. Let's run another command: Now Django knows to include the ``polls`` app. Let's run another command:
.. code-block:: bash .. code-block:: console
$ python manage.py makemigrations polls $ python manage.py makemigrations polls
@ -464,7 +464,7 @@ schema automatically - that's called :djadmin:`migrate`, and we'll come to it in
moment - but first, let's see what SQL that migration would run. The moment - but first, let's see what SQL that migration would run. The
:djadmin:`sqlmigrate` command takes migration names and returns their SQL: :djadmin:`sqlmigrate` command takes migration names and returns their SQL:
.. code-block:: bash .. code-block:: console
$ python manage.py sqlmigrate polls 0001 $ python manage.py sqlmigrate polls 0001
@ -534,7 +534,7 @@ your project without making migrations or touching the database.
Now, run :djadmin:`migrate` again to create those model tables in your database: Now, run :djadmin:`migrate` again to create those model tables in your database:
.. code-block:: bash .. code-block:: console
$ python manage.py migrate $ python manage.py migrate
Operations to perform: Operations to perform:
@ -580,7 +580,7 @@ Playing with the API
Now, let's hop into the interactive Python shell and play around with the free Now, let's hop into the interactive Python shell and play around with the free
API Django gives you. To invoke the Python shell, use this command: API Django gives you. To invoke the Python shell, use this command:
.. code-block:: bash .. code-block:: console
$ python manage.py shell $ python manage.py shell

View File

@ -27,7 +27,7 @@ Creating an admin user
First we'll need to create a user who can login to the admin site. Run the First we'll need to create a user who can login to the admin site. Run the
following command: following command:
.. code-block:: bash .. code-block:: console
$ python manage.py createsuperuser $ python manage.py createsuperuser
@ -60,7 +60,7 @@ server and explore it.
Recall from Tutorial 1 that you start the development server like so: Recall from Tutorial 1 that you start the development server like so:
.. code-block:: bash .. code-block:: console
$ python manage.py runserver $ python manage.py runserver
@ -522,7 +522,7 @@ template directory in the source code of Django itself
If you have difficulty finding where the Django source files are located If you have difficulty finding where the Django source files are located
on your system, run the following command: on your system, run the following command:
.. code-block:: bash .. code-block:: console
$ python -c " $ python -c "
import sys import sys

View File

@ -150,7 +150,7 @@ Unix ``grep`` utility to search for a phrase in all of the documentation. For
example, this will show you each mention of the phrase "max_length" in any example, this will show you each mention of the phrase "max_length" in any
Django document: Django document:
.. code-block:: bash .. code-block:: console
$ grep -r max_length /path/to/django/docs/ $ grep -r max_length /path/to/django/docs/
@ -163,14 +163,14 @@ You can get a local copy of the HTML documentation following a few easy steps:
plain text to HTML. You'll need to install Sphinx by either downloading plain text to HTML. You'll need to install Sphinx by either downloading
and installing the package from the Sphinx Web site, or with ``pip``: and installing the package from the Sphinx Web site, or with ``pip``:
.. code-block:: bash .. code-block:: console
$ pip install Sphinx $ pip install Sphinx
* Then, just use the included ``Makefile`` to turn the documentation into * Then, just use the included ``Makefile`` to turn the documentation into
HTML: HTML:
.. code-block:: bash .. code-block:: console
$ cd path/to/django/docs $ cd path/to/django/docs
$ make html $ make html

View File

@ -58,7 +58,7 @@ __ http://www.gaia-gis.it/gaia-sins/
On Debian/Ubuntu, you are advised to install the following packages which will On Debian/Ubuntu, you are advised to install the following packages which will
install, directly or by dependency, the required geospatial libraries: install, directly or by dependency, the required geospatial libraries:
.. code-block:: bash .. code-block:: console
$ sudo apt-get install binutils libproj-dev gdal-bin $ sudo apt-get install binutils libproj-dev gdal-bin

View File

@ -56,7 +56,7 @@ First, create a spatial database for your project.
If you are using PostGIS, create the database from the :ref:`spatial database If you are using PostGIS, create the database from the :ref:`spatial database
template <spatialdb_template>`: template <spatialdb_template>`:
.. code-block:: bash .. code-block:: console
$ createdb -T template_postgis geodjango $ createdb -T template_postgis geodjango
@ -66,7 +66,7 @@ template <spatialdb_template>`:
create a database. To create a user with ``CREATE DATABASE`` privileges in create a database. To create a user with ``CREATE DATABASE`` privileges in
PostgreSQL, use the following commands: PostgreSQL, use the following commands:
.. code-block:: bash .. code-block:: console
$ sudo su - postgres $ sudo su - postgres
$ createuser --createdb geo $ createuser --createdb geo
@ -84,14 +84,14 @@ Create a New Project
Use the standard ``django-admin`` script to create a project called Use the standard ``django-admin`` script to create a project called
``geodjango``: ``geodjango``:
.. code-block:: bash .. code-block:: console
$ django-admin startproject geodjango $ django-admin startproject geodjango
This will initialize a new project. Now, create a ``world`` Django application This will initialize a new project. Now, create a ``world`` Django application
within the ``geodjango`` project: within the ``geodjango`` project:
.. code-block:: bash .. code-block:: console
$ cd geodjango $ cd geodjango
$ python manage.py startapp world $ python manage.py startapp world
@ -137,7 +137,7 @@ The world borders data is available in this `zip file`__. Create a ``data``
directory in the ``world`` application, download the world borders data, and directory in the ``world`` application, download the world borders data, and
unzip. On GNU/Linux platforms, use the following commands: unzip. On GNU/Linux platforms, use the following commands:
.. code-block:: bash .. code-block:: console
$ mkdir world/data $ mkdir world/data
$ cd world/data $ cd world/data
@ -166,7 +166,7 @@ Use ``ogrinfo`` to examine spatial data
The GDAL ``ogrinfo`` utility allows examining the metadata of shapefiles or The GDAL ``ogrinfo`` utility allows examining the metadata of shapefiles or
other vector data sources: other vector data sources:
.. code-block:: bash .. code-block:: console
$ ogrinfo world/data/TM_WORLD_BORDERS-0.3.shp $ ogrinfo world/data/TM_WORLD_BORDERS-0.3.shp
INFO: Open of `world/data/TM_WORLD_BORDERS-0.3.shp' INFO: Open of `world/data/TM_WORLD_BORDERS-0.3.shp'
@ -177,7 +177,7 @@ other vector data sources:
layer contains polygon data. To find out more, we'll specify the layer name layer contains polygon data. To find out more, we'll specify the layer name
and use the ``-so`` option to get only the important summary information: and use the ``-so`` option to get only the important summary information:
.. code-block:: bash .. code-block:: console
$ ogrinfo -so world/data/TM_WORLD_BORDERS-0.3.shp TM_WORLD_BORDERS-0.3 $ ogrinfo -so world/data/TM_WORLD_BORDERS-0.3.shp TM_WORLD_BORDERS-0.3
INFO: Open of `world/data/TM_WORLD_BORDERS-0.3.shp' INFO: Open of `world/data/TM_WORLD_BORDERS-0.3.shp'
@ -267,7 +267,7 @@ Run ``migrate``
After defining your model, you need to sync it with the database. First, After defining your model, you need to sync it with the database. First,
create a database migration: create a database migration:
.. code-block:: bash .. code-block:: console
$ python manage.py makemigrations $ python manage.py makemigrations
Migrations for 'world': Migrations for 'world':
@ -277,7 +277,7 @@ create a database migration:
Let's look at the SQL that will generate the table for the ``WorldBorder`` Let's look at the SQL that will generate the table for the ``WorldBorder``
model: model:
.. code-block:: bash .. code-block:: console
$ python manage.py sqlmigrate world 0001 $ python manage.py sqlmigrate world 0001
@ -314,7 +314,7 @@ This command should produce the following output:
If this looks correct, run :djadmin:`migrate` to create this table in the If this looks correct, run :djadmin:`migrate` to create this table in the
database: database:
.. code-block:: bash .. code-block:: console
$ python manage.py migrate $ python manage.py migrate
Operations to perform: Operations to perform:
@ -351,7 +351,7 @@ library that can work with all the vector data sources that OGR supports.
First, invoke the Django shell: First, invoke the Django shell:
.. code-block:: bash .. code-block:: console
$ python manage.py shell $ python manage.py shell
@ -515,7 +515,7 @@ A few notes about what's going on:
Afterwards, invoke the Django shell from the ``geodjango`` project directory: Afterwards, invoke the Django shell from the ``geodjango`` project directory:
.. code-block:: bash .. code-block:: console
$ python manage.py shell $ python manage.py shell
@ -537,7 +537,7 @@ and generates a model definition and ``LayerMapping`` dictionary automatically.
The general usage of the command goes as follows: The general usage of the command goes as follows:
.. code-block:: bash .. code-block:: console
$ python manage.py ogrinspect [options] <data_source> <model_name> [options] $ python manage.py ogrinspect [options] <data_source> <model_name> [options]
@ -548,7 +548,7 @@ be used to further define how the model is generated.
For example, the following command nearly reproduces the ``WorldBorder`` model For example, the following command nearly reproduces the ``WorldBorder`` model
and mapping dictionary created above, automatically: and mapping dictionary created above, automatically:
.. code-block:: bash .. code-block:: console
$ python manage.py ogrinspect world/data/TM_WORLD_BORDERS-0.3.shp WorldBorder \ $ python manage.py ogrinspect world/data/TM_WORLD_BORDERS-0.3.shp WorldBorder \
--srid=4326 --mapping --multi --srid=4326 --mapping --multi
@ -609,7 +609,7 @@ GeoDjango adds spatial lookups to the Django ORM. For example, you
can find the country in the ``WorldBorder`` table that contains can find the country in the ``WorldBorder`` table that contains
a particular point. First, fire up the management shell: a particular point. First, fire up the management shell:
.. code-block:: bash .. code-block:: console
$ python manage.py shell $ python manage.py shell
@ -753,13 +753,13 @@ Next, edit your ``urls.py`` in the ``geodjango`` application folder as follows::
Create an admin user: Create an admin user:
.. code-block:: bash .. code-block:: console
$ python manage.py createsuperuser $ python manage.py createsuperuser
Next, start up the Django development server: Next, start up the Django development server:
.. code-block:: bash .. code-block:: console
$ python manage.py runserver $ python manage.py runserver

View File

@ -47,7 +47,7 @@ be consistent, but any example can use ``manage.py`` just as well.
Usage Usage
===== =====
.. code-block:: bash .. code-block:: console
$ django-admin <command> [options] $ django-admin <command> [options]
$ manage.py <command> [options] $ manage.py <command> [options]

View File

@ -556,7 +556,7 @@ need to reload your data. Do this after you have made the change to using
To upgrade each application to use a ``DecimalField``, you can do the To upgrade each application to use a ``DecimalField``, you can do the
following, replacing ``<app>`` in the code below with each app's name: following, replacing ``<app>`` in the code below with each app's name:
.. code-block:: bash .. code-block:: console
$ ./manage.py dumpdata --format=xml <app> > data-dump.xml $ ./manage.py dumpdata --format=xml <app> > data-dump.xml
$ ./manage.py reset <app> $ ./manage.py reset <app>
@ -685,13 +685,13 @@ Subcommands must now precede options
``django-admin.py`` and ``manage.py`` now require subcommands to precede ``django-admin.py`` and ``manage.py`` now require subcommands to precede
options. So: options. So:
.. code-block:: bash .. code-block:: console
$ django-admin.py --settings=foo.bar runserver $ django-admin.py --settings=foo.bar runserver
...no longer works and should be changed to: ...no longer works and should be changed to:
.. code-block:: bash .. code-block:: console
$ django-admin.py runserver --settings=foo.bar $ django-admin.py runserver --settings=foo.bar

View File

@ -34,7 +34,7 @@ but may not be mandatory depending on your particular database backend,
operating system and time zone. If you encounter an exception querying dates operating system and time zone. If you encounter an exception querying dates
or times, please try installing it before filing a bug. It's as simple as: or times, please try installing it before filing a bug. It's as simple as:
.. code-block:: bash .. code-block:: console
$ pip install pytz $ pip install pytz

View File

@ -140,9 +140,9 @@ uninstalling is as simple as deleting the ``django`` directory from your Python
``site-packages``. To find the directory you need to remove, you can run the ``site-packages``. To find the directory you need to remove, you can run the
following at your shell prompt (not the interactive Python prompt): following at your shell prompt (not the interactive Python prompt):
.. code-block:: bash .. code-block:: console
python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)" $ python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)"
.. _install-django-code: .. _install-django-code:
@ -256,18 +256,18 @@ latest bug fixes and improvements, follow these instructions:
2. Check out Django's main development branch (the 'trunk' or 'master') like 2. Check out Django's main development branch (the 'trunk' or 'master') like
so: so:
.. code-block:: bash .. code-block:: console
git clone git://github.com/django/django.git django-trunk $ git clone git://github.com/django/django.git django-trunk
This will create a directory ``django-trunk`` in your current directory. This will create a directory ``django-trunk`` in your current directory.
3. Make sure that the Python interpreter can load Django's code. The most 3. Make sure that the Python interpreter can load Django's code. The most
convenient way to do this is via pip_. Run the following command: convenient way to do this is via pip_. Run the following command:
.. code-block:: bash .. code-block:: console
sudo pip install -e django-trunk/ $ sudo pip install -e django-trunk/
(If using a virtualenv_ you can omit ``sudo``.) (If using a virtualenv_ you can omit ``sudo``.)
@ -302,9 +302,9 @@ with a checkout of Django's latest code in it. Then add a ``.pth`` file
containing the full path to the ``django-trunk`` directory to your system's containing the full path to the ``django-trunk`` directory to your system's
``site-packages`` directory. For example, on a Unix-like system: ``site-packages`` directory. For example, on a Unix-like system:
.. code-block:: bash .. code-block:: console
echo WORKING-DIR/django-trunk > SITE-PACKAGES-DIR/django.pth $ echo WORKING-DIR/django-trunk > SITE-PACKAGES-DIR/django.pth
In the above line, change ``WORKING-DIR/django-trunk`` to match the full path In the above line, change ``WORKING-DIR/django-trunk`` to match the full path
to your new ``django-trunk`` directory, and change ``SITE-PACKAGES-DIR`` to to your new ``django-trunk`` directory, and change ``SITE-PACKAGES-DIR`` to
@ -314,9 +314,9 @@ The location of the ``site-packages`` directory depends on the operating
system, and the location in which Python was installed. To find your system's system, and the location in which Python was installed. To find your system's
``site-packages`` location, execute the following: ``site-packages`` location, execute the following:
.. code-block:: bash .. code-block:: console
python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" $ python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
(Note that this should be run from a shell prompt, not a Python interactive (Note that this should be run from a shell prompt, not a Python interactive
prompt.) prompt.)
@ -334,9 +334,9 @@ On Unix-like systems, create a symbolic link to the file
``django-trunk/django/bin/django-admin`` 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: path, such as ``/usr/local/bin``. For example:
.. code-block:: bash .. code-block:: console
ln -s WORKING-DIR/django-trunk/django/bin/django-admin.py /usr/local/bin/ $ ln -s WORKING-DIR/django-trunk/django/bin/django-admin.py /usr/local/bin/
(In the above line, change WORKING-DIR to match the full path to your new (In the above line, change WORKING-DIR to match the full path to your new
``django-trunk`` directory.) ``django-trunk`` directory.)

View File

@ -766,9 +766,9 @@ to change the default address (in the case, for example, where the 8081 port is
already taken) then you may pass a different one to the :djadmin:`test` command already taken) then you may pass a different one to the :djadmin:`test` command
via the :djadminopt:`--liveserver` option, for example: via the :djadminopt:`--liveserver` option, for example:
.. code-block:: bash .. code-block:: console
./manage.py test --liveserver=localhost:8082 $ ./manage.py test --liveserver=localhost:8082
Another way of changing the default server address is by setting the Another way of changing the default server address is by setting the
`DJANGO_LIVE_TEST_SERVER_ADDRESS` environment variable somewhere in your `DJANGO_LIVE_TEST_SERVER_ADDRESS` environment variable somewhere in your
@ -784,9 +784,9 @@ tests might randomly fail with an "Address already in use" error. To avoid this
problem, you can pass a comma-separated list of ports or ranges of ports (at problem, you can pass a comma-separated list of ports or ranges of ports (at
least as many as the number of potential parallel processes). For example: least as many as the number of potential parallel processes). For example:
.. code-block:: bash .. code-block:: console
./manage.py test --liveserver=localhost:8082,8090-8100,9000-9200,7041 $ ./manage.py test --liveserver=localhost:8082,8090-8100,9000-9200,7041
Then, during test execution, each new live test server will try every specified Then, during test execution, each new live test server will try every specified
port until it finds one that is free and takes it. port until it finds one that is free and takes it.
@ -797,9 +797,9 @@ To demonstrate how to use ``LiveServerTestCase``, let's write a simple Selenium
test. First of all, you need to install the `selenium package`_ into your test. First of all, you need to install the `selenium package`_ into your
Python path: Python path:
.. code-block:: bash .. code-block:: console
pip install selenium $ pip install selenium
Then, add a ``LiveServerTestCase``-based test to your app's tests module Then, add a ``LiveServerTestCase``-based test to your app's tests module
(for example: ``myapp/tests.py``). The code for this test may look as follows:: (for example: ``myapp/tests.py``). The code for this test may look as follows::
@ -830,9 +830,9 @@ Then, add a ``LiveServerTestCase``-based test to your app's tests module
Finally, you may run the test as follows: Finally, you may run the test as follows:
.. code-block:: bash .. code-block:: console
./manage.py test myapp.tests.MySeleniumTests.test_login $ ./manage.py test myapp.tests.MySeleniumTests.test_login
This example will automatically open Firefox then go to the login page, enter This example will automatically open Firefox then go to the login page, enter
the credentials and press the "Log in" button. Selenium offers other drivers in the credentials and press the "Log in" button. Selenium offers other drivers in