summaryrefslogtreecommitdiff
path: root/docs/intro/tutorial02.txt
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2023-02-28 20:53:28 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-03-01 13:03:56 +0100
commit14459f80ee3a9e005989db37c26fd13bb6d2fab2 (patch)
treeeb62429ed696ed3a5389f3a676aecfc6d15a99cc /docs/intro/tutorial02.txt
parent6015bab80e28aef2669f6fac53423aa65f70cb08 (diff)
Fixed #34140 -- Reformatted code blocks in docs with blacken-docs.
Diffstat (limited to 'docs/intro/tutorial02.txt')
-rw-r--r--docs/intro/tutorial02.txt28
1 files changed, 15 insertions, 13 deletions
diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt
index e01975aeed..6ba70ddc1c 100644
--- a/docs/intro/tutorial02.txt
+++ b/docs/intro/tutorial02.txt
@@ -148,7 +148,7 @@ These concepts are represented by Python classes. Edit the
class Question(models.Model):
question_text = models.CharField(max_length=200)
- pub_date = models.DateTimeField('date published')
+ pub_date = models.DateTimeField("date published")
class Choice(models.Model):
@@ -220,13 +220,13 @@ this:
:caption: ``mysite/settings.py``
INSTALLED_APPS = [
- 'polls.apps.PollsConfig',
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
+ "polls.apps.PollsConfig",
+ "django.contrib.admin",
+ "django.contrib.auth",
+ "django.contrib.contenttypes",
+ "django.contrib.sessions",
+ "django.contrib.messages",
+ "django.contrib.staticfiles",
]
Now Django knows to include the ``polls`` app. Let's run another command:
@@ -430,11 +430,13 @@ representation of this object. Let's fix that by editing the ``Question`` model
from django.db import models
+
class Question(models.Model):
# ...
def __str__(self):
return self.question_text
+
class Choice(models.Model):
# ...
def __str__(self):
@@ -484,7 +486,7 @@ Save these changes and start a new Python interactive shell by running
# keyword arguments.
>>> Question.objects.filter(id=1)
<QuerySet [<Question: What's up?>]>
- >>> Question.objects.filter(question_text__startswith='What')
+ >>> Question.objects.filter(question_text__startswith="What")
<QuerySet [<Question: What's up?>]>
# Get the question that was published this year.
@@ -522,11 +524,11 @@ Save these changes and start a new Python interactive shell by running
<QuerySet []>
# Create three choices.
- >>> q.choice_set.create(choice_text='Not much', votes=0)
+ >>> q.choice_set.create(choice_text="Not much", votes=0)
<Choice: Not much>
- >>> q.choice_set.create(choice_text='The sky', votes=0)
+ >>> q.choice_set.create(choice_text="The sky", votes=0)
<Choice: The sky>
- >>> c = q.choice_set.create(choice_text='Just hacking again', votes=0)
+ >>> c = q.choice_set.create(choice_text="Just hacking again", votes=0)
# Choice objects have API access to their related Question objects.
>>> c.question
@@ -547,7 +549,7 @@ Save these changes and start a new Python interactive shell by running
<QuerySet [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]>
# Let's delete one of the choices. Use delete() for that.
- >>> c = q.choice_set.filter(choice_text__startswith='Just hacking')
+ >>> c = q.choice_set.filter(choice_text__startswith="Just hacking")
>>> c.delete()
For more information on model relations, see :doc:`Accessing related objects