diff options
Diffstat (limited to 'docs/intro/tutorial03.txt')
| -rw-r--r-- | docs/intro/tutorial03.txt | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt index 82d0d85cec..b9c9d2b54e 100644 --- a/docs/intro/tutorial03.txt +++ b/docs/intro/tutorial03.txt @@ -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> |
