From 14459f80ee3a9e005989db37c26fd13bb6d2fab2 Mon Sep 17 00:00:00 2001 From: django-bot Date: Tue, 28 Feb 2023 20:53:28 +0100 Subject: Fixed #34140 -- Reformatted code blocks in docs with blacken-docs. --- docs/intro/tutorial02.txt | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'docs/intro/tutorial02.txt') 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) ]> - >>> Question.objects.filter(question_text__startswith='What') + >>> Question.objects.filter(question_text__startswith="What") ]> # Get the question that was published this year. @@ -522,11 +524,11 @@ Save these changes and start a new Python interactive shell by running # Create three choices. - >>> q.choice_set.create(choice_text='Not much', votes=0) + >>> q.choice_set.create(choice_text="Not much", votes=0) - >>> q.choice_set.create(choice_text='The sky', votes=0) + >>> q.choice_set.create(choice_text="The sky", votes=0) - >>> 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 , , ]> # 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 -- cgit v1.3