From 1283458baae482c2bbb22c842b1db6c832c953f3 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 29 Dec 2021 12:16:16 +0100 Subject: [PATCH] Added default values to Entry's fields in making queries docs. This makes it easier to create a data in examples. --- docs/topics/db/queries.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt index eb68c7b4da..d32bca9e30 100644 --- a/docs/topics/db/queries.txt +++ b/docs/topics/db/queries.txt @@ -17,6 +17,8 @@ models, which comprise a blog application: .. code-block:: python + from datetime import date + from django.db import models class Blog(models.Model): @@ -38,11 +40,11 @@ models, which comprise a blog application: headline = models.CharField(max_length=255) body_text = models.TextField() pub_date = models.DateField() - mod_date = models.DateField() + mod_date = models.DateField(default=date.today) authors = models.ManyToManyField(Author) - number_of_comments = models.IntegerField() - number_of_pingbacks = models.IntegerField() - rating = models.IntegerField() + number_of_comments = models.IntegerField(default=0) + number_of_pingbacks = models.IntegerField(default=0) + rating = models.IntegerField(default=5) def __str__(self): return self.headline