Fixed docs build with sphinxcontrib-spelling 7.5.0+.

sphinxcontrib-spelling 7.5.0+ includes captions of figures in the set
of nodes for which the text is checked.
This commit is contained in:
Mariusz Felisiak 2022-05-31 07:40:54 +02:00
parent 1058fc7023
commit ac90529cc5
31 changed files with 128 additions and 127 deletions

View file

@ -26,7 +26,7 @@ representing your models -- so far, it's been solving many years' worth of
database-schema problems. Here's a quick example:
.. code-block:: python
:caption: mysite/news/models.py
:caption: ``mysite/news/models.py``
from django.db import models
@ -146,7 +146,7 @@ a website that lets authenticated users add, change and delete objects. The
only step required is to register your model in the admin site:
.. code-block:: python
:caption: mysite/news/models.py
:caption: ``mysite/news/models.py``
from django.db import models
@ -157,7 +157,7 @@ only step required is to register your model in the admin site:
reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE)
.. code-block:: python
:caption: mysite/news/admin.py
:caption: ``mysite/news/admin.py``
from django.contrib import admin
@ -189,7 +189,7 @@ Here's what a URLconf might look like for the ``Reporter``/``Article``
example above:
.. code-block:: python
:caption: mysite/news/urls.py
:caption: ``mysite/news/urls.py``
from django.urls import path
@ -229,7 +229,7 @@ and renders the template with the retrieved data. Here's an example view for
``year_archive`` from above:
.. code-block:: python
:caption: mysite/news/views.py
:caption: ``mysite/news/views.py``
from django.shortcuts import render
@ -258,7 +258,7 @@ Let's say the ``news/year_archive.html`` template was found. Here's what that
might look like:
.. code-block:: html+django
:caption: mysite/news/templates/news/year_archive.html
:caption: ``mysite/news/templates/news/year_archive.html``
{% extends "base.html" %}
@ -299,7 +299,7 @@ Here's what the "base.html" template, including the use of :doc:`static files
</howto/static-files/index>`, might look like:
.. code-block:: html+django
:caption: mysite/templates/base.html
:caption: ``mysite/templates/base.html``
{% load static %}
<html>

View file

@ -144,7 +144,7 @@ this. For a small app like polls, this process isn't too difficult.
#. Create a file ``django-polls/README.rst`` with the following contents:
.. code-block:: rst
:caption: django-polls/README.rst
:caption: ``django-polls/README.rst``
=====
Polls
@ -192,14 +192,14 @@ this. For a small app like polls, this process isn't too difficult.
following contents:
.. code-block:: toml
:caption: django-polls/pyproject.toml
:caption: ``django-polls/pyproject.toml``
[build-system]
requires = ['setuptools>=40.8.0', 'wheel']
build-backend = 'setuptools.build_meta:__legacy__'
.. code-block:: ini
:caption: django-polls/setup.cfg
:caption: ``django-polls/setup.cfg``
[metadata]
name = django-polls
@ -233,7 +233,7 @@ this. For a small app like polls, this process isn't too difficult.
Django >= X.Y # Replace "X.Y" as appropriate
.. code-block:: python
:caption: django-polls/setup.py
:caption: ``django-polls/setup.py``
from setuptools import setup
@ -247,7 +247,7 @@ this. For a small app like polls, this process isn't too difficult.
contents:
.. code-block:: text
:caption: django-polls/MANIFEST.in
:caption: ``django-polls/MANIFEST.in``
include LICENSE
include README.rst

View file

@ -245,7 +245,7 @@ Let's write the first view. Open the file ``polls/views.py``
and put the following Python code in it:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.http import HttpResponse
@ -273,7 +273,7 @@ Your app directory should now look like::
In the ``polls/urls.py`` file include the following code:
.. code-block:: python
:caption: polls/urls.py
:caption: ``polls/urls.py``
from django.urls import path
@ -288,7 +288,7 @@ The next step is to point the root URLconf at the ``polls.urls`` module. In
:func:`~django.urls.include` in the ``urlpatterns`` list, so you have:
.. code-block:: python
:caption: mysite/urls.py
:caption: ``mysite/urls.py``
from django.contrib import admin
from django.urls import include, path

View file

@ -141,7 +141,7 @@ These concepts are represented by Python classes. Edit the
:file:`polls/models.py` file so it looks like this:
.. code-block:: python
:caption: polls/models.py
:caption: ``polls/models.py``
from django.db import models
@ -217,7 +217,7 @@ add that dotted path to the :setting:`INSTALLED_APPS` setting. It'll look like
this:
.. code-block:: python
:caption: mysite/settings.py
:caption: ``mysite/settings.py``
INSTALLED_APPS = [
'polls.apps.PollsConfig',
@ -424,7 +424,7 @@ representation of this object. Let's fix that by editing the ``Question`` model
``Choice``:
.. code-block:: python
:caption: polls/models.py
:caption: ``polls/models.py``
from django.db import models
@ -448,7 +448,7 @@ automatically-generated admin.
Let's also add a custom method to this model:
.. code-block:: python
:caption: polls/models.py
:caption: ``polls/models.py``
import datetime
@ -646,7 +646,7 @@ have an admin interface. To do this, open the :file:`polls/admin.py` file, and
edit it to look like this:
.. code-block:: python
:caption: polls/admin.py
:caption: ``polls/admin.py``
from django.contrib import admin

View file

@ -70,7 +70,7 @@ Now let's add a few more views to ``polls/views.py``. These views are
slightly different, because they take an argument:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
def detail(request, question_id):
return HttpResponse("You're looking at question %s." % question_id)
@ -86,7 +86,7 @@ Wire these new views into the ``polls.urls`` module by adding the following
:func:`~django.urls.path` calls:
.. code-block:: python
:caption: polls/urls.py
:caption: ``polls/urls.py``
from django.urls import path
@ -147,7 +147,7 @@ view, which displays the latest 5 poll questions in the system, separated by
commas, according to publication date:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.http import HttpResponse
@ -196,7 +196,7 @@ Django as ``polls/index.html``.
Put the following code in that template:
.. code-block:: html+django
:caption: polls/templates/polls/index.html
:caption: ``polls/templates/polls/index.html``
{% if latest_question_list %}
<ul>
@ -218,7 +218,7 @@ __ https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Gett
Now let's update our ``index`` view in ``polls/views.py`` to use the template:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.http import HttpResponse
from django.template import loader
@ -251,7 +251,7 @@ template. Django provides a shortcut. Here's the full ``index()`` view,
rewritten:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.shortcuts import render
@ -280,7 +280,7 @@ Now, let's tackle the question detail view -- the page that displays the questio
for a given poll. Here's the view:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.http import Http404
from django.shortcuts import render
@ -302,7 +302,7 @@ later, but if you'd like to quickly get the above example working, a file
containing just:
.. code-block:: html+django
:caption: polls/templates/polls/detail.html
:caption: ``polls/templates/polls/detail.html``
{{ question }}
@ -316,7 +316,7 @@ and raise :exc:`~django.http.Http404` if the object doesn't exist. Django
provides a shortcut. Here's the ``detail()`` view, rewritten:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.shortcuts import get_object_or_404, render
@ -358,7 +358,7 @@ variable ``question``, here's what the ``polls/detail.html`` template might look
like:
.. code-block:: html+django
:caption: polls/templates/polls/detail.html
:caption: ``polls/templates/polls/detail.html``
<h1>{{ question.question_text }}</h1>
<ul>
@ -432,7 +432,7 @@ The answer is to add namespaces to your URLconf. In the ``polls/urls.py``
file, go ahead and add an ``app_name`` to set the application namespace:
.. code-block:: python
:caption: polls/urls.py
:caption: ``polls/urls.py``
from django.urls import path
@ -449,14 +449,14 @@ file, go ahead and add an ``app_name`` to set the application namespace:
Now change your ``polls/index.html`` template from:
.. code-block:: html+django
:caption: polls/templates/polls/index.html
:caption: ``polls/templates/polls/index.html``
<li><a href="{% url 'detail' question.id %}">{{ question.question_text }}</a></li>
to point at the namespaced detail view:
.. code-block:: html+django
:caption: polls/templates/polls/index.html
:caption: ``polls/templates/polls/index.html``
<li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>

View file

@ -18,7 +18,7 @@ Let's update our poll detail template ("polls/detail.html") from the last
tutorial, so that the template contains an HTML ``<form>`` element:
.. code-block:: html+django
:caption: polls/templates/polls/detail.html
:caption: ``polls/templates/polls/detail.html``
<form action="{% url 'polls:vote' question.id %}" method="post">
{% csrf_token %}
@ -64,7 +64,7 @@ something with it. Remember, in :doc:`Tutorial 3 </intro/tutorial03>`, we
created a URLconf for the polls application that includes this line:
.. code-block:: python
:caption: polls/urls.py
:caption: ``polls/urls.py``
path('<int:question_id>/vote/', views.vote, name='vote'),
@ -72,7 +72,7 @@ We also created a dummy implementation of the ``vote()`` function. Let's
create a real version. Add the following to ``polls/views.py``:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
@ -152,7 +152,7 @@ After somebody votes in a question, the ``vote()`` view redirects to the results
page for the question. Let's write that view:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.shortcuts import get_object_or_404, render
@ -168,7 +168,7 @@ redundancy later.
Now, create a ``polls/results.html`` template:
.. code-block:: html+django
:caption: polls/templates/polls/results.html
:caption: ``polls/templates/polls/results.html``
<h1>{{ question.question_text }}</h1>
@ -240,7 +240,7 @@ Amend URLconf
First, open the ``polls/urls.py`` URLconf and change it like so:
.. code-block:: python
:caption: polls/urls.py
:caption: ``polls/urls.py``
from django.urls import path
@ -265,7 +265,7 @@ views and use Django's generic views instead. To do so, open the
``polls/views.py`` file and change it like so:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render

View file

@ -172,7 +172,7 @@ whose name begins with ``test``.
Put the following in the ``tests.py`` file in the ``polls`` application:
.. code-block:: python
:caption: polls/tests.py
:caption: ``polls/tests.py``
import datetime
@ -261,7 +261,7 @@ return ``False`` if its ``pub_date`` is in the future. Amend the method in
past:
.. code-block:: python
:caption: polls/models.py
:caption: ``polls/models.py``
def was_published_recently(self):
now = timezone.now()
@ -297,7 +297,7 @@ Add two more test methods to the same class, to test the behavior of the method
more comprehensively:
.. code-block:: python
:caption: polls/tests.py
:caption: ``polls/tests.py``
def test_was_published_recently_with_old_question(self):
"""
@ -413,7 +413,7 @@ In :doc:`Tutorial 4 </intro/tutorial04>` we introduced a class-based view,
based on :class:`~django.views.generic.list.ListView`:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
class IndexView(generic.ListView):
template_name = 'polls/index.html'
@ -428,14 +428,14 @@ checks the date by comparing it with ``timezone.now()``. First we need to add
an import:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
from django.utils import timezone
and then we must amend the ``get_queryset`` method like so:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
def get_queryset(self):
"""
@ -463,7 +463,7 @@ our :djadmin:`shell` session above.
Add the following to ``polls/tests.py``:
.. code-block:: python
:caption: polls/tests.py
:caption: ``polls/tests.py``
from django.urls import reverse
@ -471,7 +471,7 @@ and we'll create a shortcut function to create questions as well as a new test
class:
.. code-block:: python
:caption: polls/tests.py
:caption: ``polls/tests.py``
def create_question(question_text, days):
"""
@ -572,7 +572,7 @@ the *index*, users can still reach them if they know or guess the right URL. So
we need to add a similar constraint to ``DetailView``:
.. code-block:: python
:caption: polls/views.py
:caption: ``polls/views.py``
class DetailView(generic.DetailView):
...
@ -587,7 +587,7 @@ is in the past can be displayed, and that one with a ``pub_date`` in the future
is not:
.. code-block:: python
:caption: polls/tests.py
:caption: ``polls/tests.py``
class QuestionDetailViewTests(TestCase):
def test_future_question(self):

View file

@ -61,7 +61,7 @@ the path for templates.
Put the following code in that stylesheet (``polls/static/polls/style.css``):
.. code-block:: css
:caption: polls/static/polls/style.css
:caption: ``polls/static/polls/style.css``
li a {
color: green;
@ -70,7 +70,7 @@ Put the following code in that stylesheet (``polls/static/polls/style.css``):
Next, add the following at the top of ``polls/templates/polls/index.html``:
.. code-block:: html+django
:caption: polls/templates/polls/index.html
:caption: ``polls/templates/polls/index.html``
{% load static %}
@ -103,7 +103,7 @@ Then, add a reference to your image in your stylesheet
(``polls/static/polls/style.css``):
.. code-block:: css
:caption: polls/static/polls/style.css
:caption: ``polls/static/polls/style.css``
body {
background: white url("images/background.png") no-repeat;

View file

@ -24,7 +24,7 @@ Let's see how this works by reordering the fields on the edit form. Replace
the ``admin.site.register(Question)`` line with:
.. code-block:: python
:caption: polls/admin.py
:caption: ``polls/admin.py``
from django.contrib import admin
@ -53,7 +53,7 @@ And speaking of forms with dozens of fields, you might want to split the form
up into fieldsets:
.. code-block:: python
:caption: polls/admin.py
:caption: ``polls/admin.py``
from django.contrib import admin
@ -87,7 +87,7 @@ There are two ways to solve this problem. The first is to register ``Choice``
with the admin just as we did with ``Question``:
.. code-block:: python
:caption: polls/admin.py
:caption: ``polls/admin.py``
from django.contrib import admin
@ -121,7 +121,7 @@ Remove the ``register()`` call for the ``Choice`` model. Then, edit the ``Questi
registration code to read:
.. code-block:: python
:caption: polls/admin.py
:caption: ``polls/admin.py``
from django.contrib import admin
@ -168,7 +168,7 @@ tabular way of displaying inline related objects. To use it, change the
``ChoiceInline`` declaration to read:
.. code-block:: python
:caption: polls/admin.py
:caption: ``polls/admin.py``
class ChoiceInline(admin.TabularInline):
#...
@ -200,7 +200,7 @@ tuple of field names to display, as columns, on the change list page for the
object:
.. code-block:: python
:caption: polls/admin.py
:caption: ``polls/admin.py``
class QuestionAdmin(admin.ModelAdmin):
# ...
@ -210,7 +210,7 @@ For good measure, let's also include the ``was_published_recently()`` method
from :doc:`Tutorial 2 </intro/tutorial02>`:
.. code-block:: python
:caption: polls/admin.py
:caption: ``polls/admin.py``
class QuestionAdmin(admin.ModelAdmin):
# ...
@ -232,7 +232,7 @@ You can improve that by using the :func:`~django.contrib.admin.display`
decorator on that method (in :file:`polls/models.py`), as follows:
.. code-block:: python
:caption: polls/models.py
:caption: ``polls/models.py``
from django.contrib import admin
@ -310,7 +310,7 @@ Open your settings file (:file:`mysite/settings.py`, remember) and add a
:setting:`DIRS <TEMPLATES-DIRS>` option in the :setting:`TEMPLATES` setting:
.. code-block:: python
:caption: mysite/settings.py
:caption: ``mysite/settings.py``
TEMPLATES = [
{