summaryrefslogtreecommitdiff
path: root/docs/intro/tutorial01.txt
diff options
context:
space:
mode:
authorM Nasimul Haque <nasim.haque@gmail.com>2013-09-23 23:23:47 +0100
committerTim Graham <timograham@gmail.com>2013-10-14 13:00:57 -0400
commitd07d6ae1167f93f2e88b3743c070003a66a31b35 (patch)
tree7e492b8bed053b01f728a10702276895cf47c8a2 /docs/intro/tutorial01.txt
parente077224f4ad69a68ae58a373ef69941272d3656c (diff)
Fixed #20910 -- Added a "snippet" sphinx directive to allow prefixing a filename.
Thanks Marc Tamlyn for the suggestion.
Diffstat (limited to 'docs/intro/tutorial01.txt')
-rw-r--r--docs/intro/tutorial01.txt20
1 files changed, 16 insertions, 4 deletions
diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt
index dd40a47548..8ddfc96edc 100644
--- a/docs/intro/tutorial01.txt
+++ b/docs/intro/tutorial01.txt
@@ -344,7 +344,10 @@ the text of the choice and a vote tally. Each ``Choice`` is associated with a
``Question``.
These concepts are represented by simple Python classes. Edit the
-:file:`polls/models.py` file so it looks like this::
+:file:`polls/models.py` file so it looks like this:
+
+.. snippet::
+ :filename: polls/models.py
from django.db import models
@@ -415,7 +418,10 @@ But first we need to tell our project that the ``polls`` app is installed.
Edit the :file:`mysite/settings.py` file again, and change the
:setting:`INSTALLED_APPS` setting to include the string ``'polls'``. So it'll
-look like this::
+look like this:
+
+.. snippet::
+ :filename: mysite/settings.py
INSTALLED_APPS = (
'django.contrib.admin',
@@ -589,7 +595,10 @@ of this object. Let's fix that by editing the ``Question`` model (in the
``polls/models.py`` file) and adding a
:meth:`~django.db.models.Model.__unicode__` method to both ``Question`` and
``Choice``. On Python 3, simply replace ``__unicode__`` by ``__str__`` in the
-following example::
+following example:
+
+.. snippet::
+ :filename: polls/models.py
from django.db import models
@@ -633,7 +642,10 @@ admin.
luck, things should Just Work for you.
Note these are normal Python methods. Let's add a custom method, just for
-demonstration::
+demonstration:
+
+.. snippet::
+ :filename: polls/models.py
import datetime
from django.utils import timezone