summaryrefslogtreecommitdiff
path: root/docs/topics
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-09-08 11:00:04 -0400
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-09-08 11:00:04 -0400
commite69348b4e7f07ef927edaecc7126901fc91c79d0 (patch)
treee3bf89867455ee918f69245a3d4c7be5535ad155 /docs/topics
parentb7d3b057f32ed6aa7ee0941e1f0dec9d3e9223a3 (diff)
Avoided mixing dates and datetimes in the examples.
Refs #16023.
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/db/examples/many_to_one.txt8
-rw-r--r--docs/topics/db/queries.txt12
2 files changed, 10 insertions, 10 deletions
diff --git a/docs/topics/db/examples/many_to_one.txt b/docs/topics/db/examples/many_to_one.txt
index 0a9978b8d1..c869362d16 100644
--- a/docs/topics/db/examples/many_to_one.txt
+++ b/docs/topics/db/examples/many_to_one.txt
@@ -42,8 +42,8 @@ Create a few Reporters::
Create an Article::
- >>> from datetime import datetime
- >>> a = Article(id=None, headline="This is a test", pub_date=datetime(2005, 7, 27), reporter=r)
+ >>> from datetime import date
+ >>> a = Article(id=None, headline="This is a test", pub_date=date(2005, 7, 27), reporter=r)
>>> a.save()
>>> a.reporter.id
@@ -65,7 +65,7 @@ database, which always returns unicode strings)::
Create an Article via the Reporter object::
- >>> new_article = r.article_set.create(headline="John's second story", pub_date=datetime(2005, 7, 29))
+ >>> new_article = r.article_set.create(headline="John's second story", pub_date=date(2005, 7, 29))
>>> new_article
<Article: John's second story>
>>> new_article.reporter
@@ -75,7 +75,7 @@ Create an Article via the Reporter object::
Create a new article, and add it to the article set::
- >>> new_article2 = Article(headline="Paul's story", pub_date=datetime(2006, 1, 17))
+ >>> new_article2 = Article(headline="Paul's story", pub_date=date(2006, 1, 17))
>>> r.article_set.add(new_article2)
>>> new_article2.reporter
<Reporter: John Smith>
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index 12e9b447b3..5385b2a72d 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -35,8 +35,8 @@ models, which comprise a Weblog application:
blog = models.ForeignKey(Blog)
headline = models.CharField(max_length=255)
body_text = models.TextField()
- pub_date = models.DateTimeField()
- mod_date = models.DateTimeField()
+ pub_date = models.DateField()
+ mod_date = models.DateField()
authors = models.ManyToManyField(Author)
n_comments = models.IntegerField()
n_pingbacks = models.IntegerField()
@@ -233,7 +233,7 @@ refinements together. For example::
>>> Entry.objects.filter(
... headline__startswith='What'
... ).exclude(
- ... pub_date__gte=datetime.now()
+ ... pub_date__gte=datetime.date.today()
... ).filter(
... pub_date__gte=datetime(2005, 1, 30)
... )
@@ -258,8 +258,8 @@ stored, used and reused.
Example::
>> q1 = Entry.objects.filter(headline__startswith="What")
- >> q2 = q1.exclude(pub_date__gte=datetime.now())
- >> q3 = q1.filter(pub_date__gte=datetime.now())
+ >> q2 = q1.exclude(pub_date__gte=datetime.date.today())
+ >> q3 = q1.filter(pub_date__gte=datetime.date.today())
These three ``QuerySets`` are separate. The first is a base
:class:`~django.db.models.query.QuerySet` containing all entries that contain a
@@ -282,7 +282,7 @@ actually run the query until the :class:`~django.db.models.query.QuerySet` is
*evaluated*. Take a look at this example::
>>> q = Entry.objects.filter(headline__startswith="What")
- >>> q = q.filter(pub_date__lte=datetime.now())
+ >>> q = q.filter(pub_date__lte=datetime.date.today())
>>> q = q.exclude(body_text__icontains="food")
>>> print(q)