per page, with , order by , clip by
Results of 1 - 1 of about 1 for discount (0.001 sec.)
条件式 9414
条件式 Conditional expressions let you use if ... elif ... else logic within filters, annotations, aggregations, and updates. A conditional expression evaluates a series of conditions for each row of a table and returns the matching result ... ccount_type = Client . PLATINUM , ... registered_on = date . today () - timedelta ( days = 10 * 365 ), ... ) >>> # Get the discount for each Client based on the account type >>> Client . objects . annotate ( ... discount = Case ( ... When ( account_type ... t_type = Client . PLATINUM , then = Value ( "10%" )), ... default = Value ( "0%" ), ... ), ... ) . values_list ( "name" , "discount" ) <QuerySet [('Jane Doe', '0%'), ('James Smith', '5%'), ('Jack Black', '10%')]> Case() は任意の数の When() オブジェクトを ... _ago = date . today () - timedelta ( days = 30 ) >>> a_year_ago = date . today () - timedelta ( days = 365 ) >>> # Get the discount for each Client based on the registration date >>> Client . objects . annotate ( ... discount = Case ( ... When ( register ...
https://man.mtool.work/django/6.1/ref/models/conditional-expressions.html
PREV 1 NEXT