From 1853e2dbf2e290ec04e3389d523bbe4bad94a42e Mon Sep 17 00:00:00 2001 From: Curtis Maloney Date: Tue, 11 Sep 2018 03:00:34 +1000 Subject: [2.1.x] Refs #20910 -- Replaced snippet directive with code-block. Backport of c49ea6f5911296dcb40190c905e38b43cdc7c7a3 from master --- docs/intro/overview.txt | 28 ++++++++++++------------ docs/intro/reusable-apps.txt | 12 +++++----- docs/intro/tutorial01.txt | 12 +++++----- docs/intro/tutorial02.txt | 20 ++++++++--------- docs/intro/tutorial03.txt | 52 ++++++++++++++++++++++---------------------- docs/intro/tutorial04.txt | 28 ++++++++++++------------ docs/intro/tutorial05.txt | 40 +++++++++++++++++----------------- docs/intro/tutorial06.txt | 12 +++++----- docs/intro/tutorial07.txt | 36 +++++++++++++++--------------- 9 files changed, 120 insertions(+), 120 deletions(-) (limited to 'docs/intro') diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt index e091ab0229..82b7a71a60 100644 --- a/docs/intro/overview.txt +++ b/docs/intro/overview.txt @@ -25,8 +25,8 @@ The :doc:`data-model syntax ` offers many rich ways of representing your models -- so far, it's been solving many years' worth of database-schema problems. Here's a quick example: -.. snippet:: - :filename: mysite/news/models.py +.. code-block:: python + :caption: mysite/news/models.py from django.db import models @@ -145,8 +145,8 @@ production ready :doc:`administrative interface ` -- a website that lets authenticated users add, change and delete objects. It's as easy as registering your model in the admin site: -.. snippet:: - :filename: mysite/news/models.py +.. code-block:: python + :caption: mysite/news/models.py from django.db import models @@ -156,8 +156,8 @@ as easy as registering your model in the admin site: content = models.TextField() reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE) -.. snippet:: - :filename: mysite/news/admin.py +.. code-block:: python + :caption: mysite/news/admin.py from django.contrib import admin @@ -188,8 +188,8 @@ to decouple URLs from Python code. Here's what a URLconf might look like for the ``Reporter``/``Article`` example above: -.. snippet:: - :filename: mysite/news/urls.py +.. code-block:: python + :caption: mysite/news/urls.py from django.urls import path @@ -228,8 +228,8 @@ Generally, a view retrieves data according to the parameters, loads a template and renders the template with the retrieved data. Here's an example view for ``year_archive`` from above: -.. snippet:: - :filename: mysite/news/views.py +.. code-block:: python + :caption: mysite/news/views.py from django.shortcuts import render @@ -257,8 +257,8 @@ in the first directory, it checks the second, and so on. Let's say the ``news/year_archive.html`` template was found. Here's what that might look like: -.. snippet:: html+django - :filename: mysite/news/templates/news/year_archive.html +.. code-block:: html+django + :caption: mysite/news/templates/news/year_archive.html {% extends "base.html" %} @@ -298,8 +298,8 @@ in templates: each template has to define only what's unique to that template. Here's what the "base.html" template, including the use of :doc:`static files `, might look like: -.. snippet:: html+django - :filename: mysite/templates/base.html +.. code-block:: html+django + :caption: mysite/templates/base.html {% load static %} diff --git a/docs/intro/reusable-apps.txt b/docs/intro/reusable-apps.txt index 8b71b523a4..e76bab8173 100644 --- a/docs/intro/reusable-apps.txt +++ b/docs/intro/reusable-apps.txt @@ -141,8 +141,8 @@ this. For a small app like polls, this process isn't too difficult. 3. Create a file ``django-polls/README.rst`` with the following contents: - .. snippet:: - :filename: django-polls/README.rst + .. code-block:: rst + :caption: django-polls/README.rst ===== Polls @@ -188,8 +188,8 @@ this. For a small app like polls, this process isn't too difficult. explanation. Create a file ``django-polls/setup.py`` with the following contents: - .. snippet:: - :filename: django-polls/setup.py + .. code-block:: python + :caption: django-polls/setup.py import os from setuptools import find_packages, setup @@ -233,8 +233,8 @@ this. For a small app like polls, this process isn't too difficult. file, create a file ``django-polls/MANIFEST.in`` with the following contents: - .. snippet:: - :filename: django-polls/MANIFEST.in + .. code-block:: text + :caption: django-polls/MANIFEST.in include LICENSE include README.rst diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt index aca496580e..d3d2fe3325 100644 --- a/docs/intro/tutorial01.txt +++ b/docs/intro/tutorial01.txt @@ -243,8 +243,8 @@ Write your first view Let's write the first view. Open the file ``polls/views.py`` and put the following Python code in it: -.. snippet:: - :filename: polls/views.py +.. code-block:: python + :caption: polls/views.py from django.http import HttpResponse @@ -271,8 +271,8 @@ Your app directory should now look like:: In the ``polls/urls.py`` file include the following code: -.. snippet:: - :filename: polls/urls.py +.. code-block:: python + :caption: polls/urls.py from django.urls import path @@ -286,8 +286,8 @@ The next step is to point the root URLconf at the ``polls.urls`` module. In ``mysite/urls.py``, add an import for ``django.urls.include`` and insert an :func:`~django.urls.include` in the ``urlpatterns`` list, so you have: -.. snippet:: - :filename: mysite/urls.py +.. code-block:: python + :caption: mysite/urls.py from django.contrib import admin from django.urls import include, path diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index c1f0aeef46..9046d167b0 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -135,8 +135,8 @@ with a ``Question``. These concepts are represented by simple Python classes. Edit the :file:`polls/models.py` file so it looks like this: -.. snippet:: - :filename: polls/models.py +.. code-block:: python + :caption: polls/models.py from django.db import models @@ -211,8 +211,8 @@ is ``'polls.apps.PollsConfig'``. Edit the :file:`mysite/settings.py` file and add that dotted path to the :setting:`INSTALLED_APPS` setting. It'll look like this: -.. snippet:: - :filename: mysite/settings.py +.. code-block:: python + :caption: mysite/settings.py INSTALLED_APPS = [ 'polls.apps.PollsConfig', @@ -423,8 +423,8 @@ representation of this object. Let's fix that by editing the ``Question`` model :meth:`~django.db.models.Model.__str__` method to both ``Question`` and ``Choice``: -.. snippet:: - :filename: polls/models.py +.. code-block:: python + :caption: polls/models.py from django.db import models @@ -446,8 +446,8 @@ automatically-generated admin. Note these are normal Python methods. Let's add a custom method, just for demonstration: -.. snippet:: - :filename: polls/models.py +.. code-block:: python + :caption: polls/models.py import datetime @@ -644,8 +644,8 @@ Just one thing to do: we need to tell the admin that ``Question`` objects have an admin interface. To do this, open the :file:`polls/admin.py` file, and edit it to look like this: -.. snippet:: - :filename: polls/admin.py +.. code-block:: python + :caption: polls/admin.py from django.contrib import admin diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt index 32c0c99fd1..de84ad0612 100644 --- a/docs/intro/tutorial03.txt +++ b/docs/intro/tutorial03.txt @@ -64,8 +64,8 @@ Writing more views Now let's add a few more views to ``polls/views.py``. These views are slightly different, because they take an argument: -.. snippet:: - :filename: polls/views.py +.. code-block:: python + :caption: polls/views.py def detail(request, question_id): return HttpResponse("You're looking at question %s." % question_id) @@ -80,8 +80,8 @@ slightly different, because they take an argument: Wire these new views into the ``polls.urls`` module by adding the following :func:`~django.urls.path` calls: -.. snippet:: - :filename: polls/urls.py +.. code-block:: python + :caption: polls/urls.py from django.urls import path @@ -147,8 +147,8 @@ in :doc:`Tutorial 2 `. Here's one stab at a new ``index()`` view, which displays the latest 5 poll questions in the system, separated by commas, according to publication date: -.. snippet:: - :filename: polls/views.py +.. code-block:: python + :caption: polls/views.py from django.http import HttpResponse @@ -196,8 +196,8 @@ Django simply as ``polls/index.html``. Put the following code in that template: -.. snippet:: html+django - :filename: polls/templates/polls/index.html +.. code-block:: html+django + :caption: polls/templates/polls/index.html {% if latest_question_list %}