summaryrefslogtreecommitdiff
path: root/docs/howto
diff options
context:
space:
mode:
authorCarlton Gibson <carlton.gibson@noumenal.es>2023-02-09 16:48:46 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-02-10 21:12:06 +0100
commitb784768eef75afb32f6d2ce7166551a528bce0ec (patch)
treea375a57a50f1766538ea8a62ec49bda352d7f2b9 /docs/howto
parent4a89aa25c91e520c247aee428782274dcf10ffd0 (diff)
[4.2.x] Refs #34140 -- Applied rst code-block to non-Python examples.
Thanks to J.V. Zammit, Paolo Melchiorre, and Mariusz Felisiak for reviews. Backport of 534ac4829764f317cf2fbc4a18354fcc998c1425 from main.
Diffstat (limited to 'docs/howto')
-rw-r--r--docs/howto/csrf.txt4
-rw-r--r--docs/howto/custom-management-commands.txt4
-rw-r--r--docs/howto/custom-template-tags.txt4
-rw-r--r--docs/howto/deployment/asgi/daphne.txt10
-rw-r--r--docs/howto/deployment/asgi/hypercorn.txt10
-rw-r--r--docs/howto/deployment/asgi/uvicorn.txt18
-rw-r--r--docs/howto/deployment/wsgi/gunicorn.txt6
-rw-r--r--docs/howto/deployment/wsgi/modwsgi.txt8
-rw-r--r--docs/howto/deployment/wsgi/uwsgi.txt18
-rw-r--r--docs/howto/legacy-databases.txt14
-rw-r--r--docs/howto/outputting-pdf.txt4
-rw-r--r--docs/howto/static-files/index.txt4
-rw-r--r--docs/howto/windows.txt25
13 files changed, 87 insertions, 42 deletions
diff --git a/docs/howto/csrf.txt b/docs/howto/csrf.txt
index 9e3024029e..3f3271454b 100644
--- a/docs/howto/csrf.txt
+++ b/docs/howto/csrf.txt
@@ -225,7 +225,9 @@ decorator so that they no longer rejects requests. In every other respect
If, for some reason, you *want* the test client to perform CSRF
checks, you can create an instance of the test client that enforces
-CSRF checks::
+CSRF checks:
+
+.. code-block:: pycon
>>> from django.test import Client
>>> csrf_client = Client(enforce_csrf_checks=True)
diff --git a/docs/howto/custom-management-commands.txt b/docs/howto/custom-management-commands.txt
index e797c15cbb..8fd168d150 100644
--- a/docs/howto/custom-management-commands.txt
+++ b/docs/howto/custom-management-commands.txt
@@ -12,7 +12,9 @@ command for the ``polls`` application from the
To do this, add a ``management/commands`` directory to the application. Django
will register a ``manage.py`` command for each Python module in that directory
-whose name doesn't begin with an underscore. For example::
+whose name doesn't begin with an underscore. For example:
+
+.. code-block:: text
polls/
__init__.py
diff --git a/docs/howto/custom-template-tags.txt b/docs/howto/custom-template-tags.txt
index 50c79cc0e9..8ff469a5d6 100644
--- a/docs/howto/custom-template-tags.txt
+++ b/docs/howto/custom-template-tags.txt
@@ -35,7 +35,9 @@ later, so be careful to pick a name that won't clash with custom tags and
filters in another app.
For example, if your custom tags/filters are in a file called
-``poll_extras.py``, your app layout might look like this::
+``poll_extras.py``, your app layout might look like this:
+
+.. code-block:: text
polls/
__init__.py
diff --git a/docs/howto/deployment/asgi/daphne.txt b/docs/howto/deployment/asgi/daphne.txt
index 94d1ac897b..5948288f07 100644
--- a/docs/howto/deployment/asgi/daphne.txt
+++ b/docs/howto/deployment/asgi/daphne.txt
@@ -2,8 +2,6 @@
How to use Django with Daphne
=============================
-.. highlight:: bash
-
Daphne_ is a pure-Python ASGI server for UNIX, maintained by members of the
Django project. It acts as the reference server for ASGI.
@@ -12,7 +10,9 @@ Django project. It acts as the reference server for ASGI.
Installing Daphne
===================
-You can install Daphne with ``pip``::
+You can install Daphne with ``pip``:
+
+.. code-block:: shell
python -m pip install daphne
@@ -24,7 +24,9 @@ Daphne server process. At its simplest, Daphne needs to be called with the
location of a module containing an ASGI application object, followed by what
the application is called (separated by a colon).
-For a typical Django project, invoking Daphne would look like::
+For a typical Django project, invoking Daphne would look like:
+
+.. code-block:: shell
daphne myproject.asgi:application
diff --git a/docs/howto/deployment/asgi/hypercorn.txt b/docs/howto/deployment/asgi/hypercorn.txt
index 28b5d06b6e..ea5ce3cc72 100644
--- a/docs/howto/deployment/asgi/hypercorn.txt
+++ b/docs/howto/deployment/asgi/hypercorn.txt
@@ -2,15 +2,15 @@
How to use Django with Hypercorn
================================
-.. highlight:: bash
-
Hypercorn_ is an ASGI server that supports HTTP/1, HTTP/2, and HTTP/3
with an emphasis on protocol support.
Installing Hypercorn
====================
-You can install Hypercorn with ``pip``::
+You can install Hypercorn with ``pip``:
+
+.. code-block:: shell
python -m pip install hypercorn
@@ -22,7 +22,9 @@ which runs ASGI applications. Hypercorn needs to be called with the
location of a module containing an ASGI application object, followed
by what the application is called (separated by a colon).
-For a typical Django project, invoking Hypercorn would look like::
+For a typical Django project, invoking Hypercorn would look like:
+
+.. code-block:: shell
hypercorn myproject.asgi:application
diff --git a/docs/howto/deployment/asgi/uvicorn.txt b/docs/howto/deployment/asgi/uvicorn.txt
index bcee952ea1..cfce90fec1 100644
--- a/docs/howto/deployment/asgi/uvicorn.txt
+++ b/docs/howto/deployment/asgi/uvicorn.txt
@@ -2,15 +2,15 @@
How to use Django with Uvicorn
==============================
-.. highlight:: bash
-
Uvicorn_ is an ASGI server based on ``uvloop`` and ``httptools``, with an
emphasis on speed.
Installing Uvicorn
==================
-You can install Uvicorn with ``pip``::
+You can install Uvicorn with ``pip``:
+
+.. code-block:: shell
python -m pip install uvicorn
@@ -22,7 +22,9 @@ applications. Uvicorn needs to be called with the location of a module
containing an ASGI application object, followed by what the application is
called (separated by a colon).
-For a typical Django project, invoking Uvicorn would look like::
+For a typical Django project, invoking Uvicorn would look like:
+
+.. code-block:: shell
python -m uvicorn myproject.asgi:application
@@ -41,11 +43,15 @@ Deploying Django using Uvicorn and Gunicorn
Gunicorn_ is a robust web server that implements process monitoring and automatic
restarts. This can be useful when running Uvicorn in a production environment.
-To install Uvicorn and Gunicorn, use the following::
+To install Uvicorn and Gunicorn, use the following:
+
+.. code-block:: shell
python -m pip install uvicorn gunicorn
-Then start Gunicorn using the Uvicorn worker class like this::
+Then start Gunicorn using the Uvicorn worker class like this:
+
+.. code-block:: shell
python -m gunicorn myproject.asgi:application -k uvicorn.workers.UvicornWorker
diff --git a/docs/howto/deployment/wsgi/gunicorn.txt b/docs/howto/deployment/wsgi/gunicorn.txt
index 6091120488..60d6620ea3 100644
--- a/docs/howto/deployment/wsgi/gunicorn.txt
+++ b/docs/howto/deployment/wsgi/gunicorn.txt
@@ -2,8 +2,6 @@
How to use Django with Gunicorn
===============================
-.. highlight:: bash
-
Gunicorn_ ('Green Unicorn') is a pure-Python WSGI server for UNIX. It has no
dependencies and can be installed using ``pip``.
@@ -23,7 +21,9 @@ Running Django in Gunicorn as a generic WSGI application
When Gunicorn is installed, a ``gunicorn`` command is available which starts
the Gunicorn server process. The simplest invocation of gunicorn is to pass the
location of a module containing a WSGI application object named
-``application``, which for a typical Django project would look like::
+``application``, which for a typical Django project would look like:
+
+.. code-block:: shell
gunicorn myproject.wsgi
diff --git a/docs/howto/deployment/wsgi/modwsgi.txt b/docs/howto/deployment/wsgi/modwsgi.txt
index c2a2d3d1bd..c81b3df48a 100644
--- a/docs/howto/deployment/wsgi/modwsgi.txt
+++ b/docs/howto/deployment/wsgi/modwsgi.txt
@@ -85,7 +85,9 @@ should put in this file, and what else you can add to it.
If you get a ``UnicodeEncodeError`` when uploading or writing files with
file names or content that contains non-ASCII characters, make sure Apache
- is configured to support UTF-8 encoding::
+ is configured to support UTF-8 encoding:
+
+ .. code-block:: shell
export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
@@ -94,7 +96,9 @@ should put in this file, and what else you can add to it.
Alternatively, if you are :ref:`using mod_wsgi daemon mode<daemon-mode>`
you can add ``lang`` and ``locale`` options to the ``WSGIDaemonProcess``
- directive::
+ directive:
+
+ .. code-block:: text
WSGIDaemonProcess example.com lang='en_US.UTF-8' locale='en_US.UTF-8'
diff --git a/docs/howto/deployment/wsgi/uwsgi.txt b/docs/howto/deployment/wsgi/uwsgi.txt
index f441d73f04..2bb49b285c 100644
--- a/docs/howto/deployment/wsgi/uwsgi.txt
+++ b/docs/howto/deployment/wsgi/uwsgi.txt
@@ -2,8 +2,6 @@
How to use Django with uWSGI
============================
-.. highlight:: bash
-
uWSGI_ is a fast, self-healing and developer/sysadmin-friendly application
container server coded in pure C.
@@ -48,7 +46,9 @@ uWSGI supports multiple ways to configure the process. See uWSGI's
.. _configuration documentation: https://uwsgi.readthedocs.io/en/latest/Configuration.html
-Here's an example command to start a uWSGI server::
+Here's an example command to start a uWSGI server:
+
+.. code-block:: shell
uwsgi --chdir=/path/to/your/project \
--module=mysite.wsgi:application \
@@ -80,7 +80,9 @@ The Django-specific options here are:
* ``env``: Should probably contain at least :envvar:`DJANGO_SETTINGS_MODULE`.
* ``home``: Optional path to your project virtual environment.
-Example ini configuration file::
+Example ini configuration file:
+
+.. code-block:: ini
[uwsgi]
chdir=/path/to/your/project
@@ -91,7 +93,9 @@ Example ini configuration file::
max-requests=5000
daemonize=/var/log/uwsgi/yourproject.log
-Example ini configuration file usage::
+Example ini configuration file usage:
+
+.. code-block:: shell
uwsgi --ini uwsgi.ini
@@ -99,7 +103,9 @@ Example ini configuration file usage::
If you get a ``UnicodeEncodeError`` when uploading files with file names
that contain non-ASCII characters, make sure uWSGI is configured to accept
- non-ASCII file names by adding this to your ``uwsgi.ini``::
+ non-ASCII file names by adding this to your ``uwsgi.ini``:
+
+ .. code-block:: ini
env = LANG=en_US.UTF-8
diff --git a/docs/howto/legacy-databases.txt b/docs/howto/legacy-databases.txt
index 052bb9d369..6204c12e50 100644
--- a/docs/howto/legacy-databases.txt
+++ b/docs/howto/legacy-databases.txt
@@ -30,15 +30,17 @@ connection:
Auto-generate the models
========================
-.. highlight:: bash
-
Django comes with a utility called :djadmin:`inspectdb` that can create models
by introspecting an existing database. You can view the output by running this
-command::
+command:
+
+.. code-block:: shell
$ python manage.py inspectdb
-Save this as a file by using standard Unix output redirection::
+Save this as a file by using standard Unix output redirection:
+
+.. code-block:: shell
$ python manage.py inspectdb > models.py
@@ -68,7 +70,9 @@ Install the core Django tables
==============================
Next, run the :djadmin:`migrate` command to install any extra needed database
-records such as admin permissions and content types::
+records such as admin permissions and content types:
+
+.. code-block:: shell
$ python manage.py migrate
diff --git a/docs/howto/outputting-pdf.txt b/docs/howto/outputting-pdf.txt
index 79bebf1f6d..fd56b96716 100644
--- a/docs/howto/outputting-pdf.txt
+++ b/docs/howto/outputting-pdf.txt
@@ -28,7 +28,9 @@ You can install ReportLab with ``pip``:
$ python -m pip install reportlab
-Test your installation by importing it in the Python interactive interpreter::
+Test your installation by importing it in the Python interactive interpreter:
+
+.. code-block:: pycon
>>> import reportlab
diff --git a/docs/howto/static-files/index.txt b/docs/howto/static-files/index.txt
index def58c5ed1..2f82cf821d 100644
--- a/docs/howto/static-files/index.txt
+++ b/docs/howto/static-files/index.txt
@@ -172,7 +172,9 @@ for gathering static files in a single directory so you can serve them easily.
STATIC_ROOT = "/var/www/example.com/static/"
-#. Run the :djadmin:`collectstatic` management command::
+#. Run the :djadmin:`collectstatic` management command:
+
+ .. code-block:: shell
$ python manage.py collectstatic
diff --git a/docs/howto/windows.txt b/docs/howto/windows.txt
index 5bd5b3594a..cd9acda543 100644
--- a/docs/howto/windows.txt
+++ b/docs/howto/windows.txt
@@ -2,7 +2,6 @@
How to install Django on Windows
================================
-.. highlight:: doscon
This document will guide you through installing Python 3.8 and Django on
Windows. It also provides instructions for setting up a virtual environment,
@@ -28,7 +27,9 @@ Download the executable installer and run it. Check the boxes next to "Install
launcher for all users (recommended)" then click "Install Now".
After installation, open the command prompt and check that the Python version
-matches the version you installed by executing::
+matches the version you installed by executing:
+
+.. code-block:: doscon
...\> py --version
@@ -60,12 +61,16 @@ environments which we will use for this guide.
To create a virtual environment for your project, open a new command prompt,
navigate to the folder where you want to create your project and then enter the
-following::
+following:
+
+.. code-block:: doscon
...\> py -m venv project-name
This will create a folder called 'project-name' if it does not already exist
-and set up the virtual environment. To activate the environment, run::
+and set up the virtual environment. To activate the environment, run:
+
+.. code-block:: doscon
...\> project-name\Scripts\activate.bat
@@ -79,7 +84,9 @@ Install Django
Django can be installed easily using ``pip`` within your virtual environment.
In the command prompt, ensure your virtual environment is active, and execute
-the following command::
+the following command:
+
+.. code-block:: doscon
...\> py -m pip install Django
@@ -100,7 +107,9 @@ for some reason this needs to be disabled, set the environmental variable
:envvar:`DJANGO_COLORS` to ``nocolor``.
On older Windows versions, or legacy terminals, colorama_ must be installed to
-enable syntax coloring::
+enable syntax coloring:
+
+.. code-block:: doscon
...\> py -m pip install colorama
@@ -119,7 +128,9 @@ Common pitfalls
* If you are connecting to the internet behind a proxy, there might be problems
in running the command ``py -m pip install Django``. Set the environment
- variables for proxy configuration in the command prompt as follows::
+ variables for proxy configuration in the command prompt as follows:
+
+ .. code-block:: doscon
...\> set http_proxy=http://username:password@proxyserver:proxyport
...\> set https_proxy=https://username:password@proxyserver:proxyport