Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django docs case when

Client.objects.annotate(
     discount=Case(
         When(account_type=Client.GOLD, then=Value('5%')),
         When(account_type=Client.PLATINUM, then=Value('10%')),
         default=Value('0%'),
     ),
 ).values_list('name', 'discount')
Source by docs.djangoproject.com #
 
PREVIOUS NEXT
Tagged: #django #docs #case
ADD COMMENT
Topic
Name
4+8 =