summaryrefslogtreecommitdiff
path: root/tests/modeltests/basic
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2009-02-08 05:08:06 +0000
committerKaren Tracey <kmtracey@gmail.com>2009-02-08 05:08:06 +0000
commitaddd3df3bd39730cd82c52d9726c9b7dbf1bdb8f (patch)
treee648cbb129dfd103af1d278aaafc0a7007ce95ea /tests/modeltests/basic
parent0326574d0ecf2eeded92d66855822dd2e602297f (diff)
Fixed #7672 -- Added a 'week_day' lookup type. Many thanks to Ross Poulton for the proposal and implementation on all built-in database backends..
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/basic')
-rw-r--r--tests/modeltests/basic/models.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/modeltests/basic/models.py b/tests/modeltests/basic/models.py
index 835c5c90cf..2dbde58256 100644
--- a/tests/modeltests/basic/models.py
+++ b/tests/modeltests/basic/models.py
@@ -74,6 +74,8 @@ datetime.datetime(2005, 7, 28, 0, 0)
<Article: Area woman programs in Python>
>>> Article.objects.get(pub_date__year=2005, pub_date__month=7, pub_date__day=28)
<Article: Area woman programs in Python>
+>>> Article.objects.get(pub_date__week_day=5)
+<Article: Area woman programs in Python>
# The "__exact" lookup type can be omitted, as a shortcut.
>>> Article.objects.get(id=1)
@@ -88,6 +90,11 @@ datetime.datetime(2005, 7, 28, 0, 0)
>>> Article.objects.filter(pub_date__year=2005, pub_date__month=7)
[<Article: Area woman programs in Python>]
+>>> Article.objects.filter(pub_date__week_day=5)
+[<Article: Area woman programs in Python>]
+>>> Article.objects.filter(pub_date__week_day=6)
+[]
+
# Django raises an Article.DoesNotExist exception for get() if the parameters
# don't match any object.
>>> Article.objects.get(id__exact=2)
@@ -100,6 +107,11 @@ Traceback (most recent call last):
...
DoesNotExist: Article matching query does not exist.
+>>> Article.objects.get(pub_date__week_day=6)
+Traceback (most recent call last):
+ ...
+DoesNotExist: Article matching query does not exist.
+
# Lookup by a primary key is the most common case, so Django provides a
# shortcut for primary-key exact lookups.
# The following is identical to articles.get(id=1).