From addd3df3bd39730cd82c52d9726c9b7dbf1bdb8f Mon Sep 17 00:00:00 2001 From: Karen Tracey Date: Sun, 8 Feb 2009 05:08:06 +0000 Subject: 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 --- tests/modeltests/basic/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/modeltests/basic') 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.objects.get(pub_date__year=2005, pub_date__month=7, pub_date__day=28) +>>> Article.objects.get(pub_date__week_day=5) + # 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.objects.filter(pub_date__week_day=5) +[] +>>> 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). -- cgit v1.3