mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.10.x] Fixed #27482 -- Doc'd an example of Case() in QuerySet.filter().
Backport of b28c6ca763 from master
			
			
This commit is contained in:
		| @@ -1279,3 +1279,17 @@ class CaseDocumentationExamples(TestCase): | ||||
|             ), | ||||
|             {'regular': 2, 'gold': 1, 'platinum': 3} | ||||
|         ) | ||||
|  | ||||
|     def test_filter_example(self): | ||||
|         a_month_ago = date.today() - timedelta(days=30) | ||||
|         a_year_ago = date.today() - timedelta(days=365) | ||||
|         self.assertQuerysetEqual( | ||||
|             Client.objects.filter( | ||||
|                 registered_on__lte=Case( | ||||
|                     When(account_type=Client.GOLD, then=a_month_ago), | ||||
|                     When(account_type=Client.PLATINUM, then=a_year_ago), | ||||
|                 ), | ||||
|             ), | ||||
|             [('Jack Black', 'P')], | ||||
|             transform=attrgetter('name', 'account_type') | ||||
|         ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user