Похожие презентации:
Money Sum Field
1.
Use Case 1Normal Sum
Model
Django Money SUM
Field
Django Money SUM
Field Tax
$15.00
$0.90
Related Model
Instance
Django Money Field
Amount
Django Money Field
Tax
$5.00
Related Model
Instance
Django Money Field
Amount
Django Money Field
Tax
$5.00
$0.30
$0.30
Related Model
Instance
Django Money Field
Amount
Django Money Field
Tax
$5.00
$0.30
2.
Use Case 2Get summed instances
> User = User.objects.get(pk=1)
User.bill.amount amount is the sum field
45$
User.bill.amount.instances
[ObjectType1, ObjectType1, ObjectType2,ObjectType5]
3.
Use Case 3Sum summed instances
> User = User.objects.get(pk=1)
User.bill.amount amount is the sum field
45$
i = User.bill.amount.instances
i
[ObjectType1, ObjectType1, ObjectType2,ObjectType5]
For t in in:
T.bill.amount
5
10
5
25
For t in in:
T.bill.amount.instances
[ObjectType12, ObjectType44, ObjectType44,ObjectType23]
[ObjectType12, ObjectType11, ObjectType424,ObjectType24213]
[ObjectType122, ObjectType434, ObjectType434,ObjectType243]
[ObjectType112, ObjectType443, ObjectType443,ObjectType223]
Basically nested Sum Money field, with a
nested instance SUM capabilities
4.
Use Case 4Filtering
User = Bill.objects.filter(var=True).values(id,amount,date,etc)
Returns objects with summed values for amount
[{“id” : 44, “amount” : {“value” : 45, “currency” : “usd”}, “date”: datetime.datetime(2016, 5, 8, 14, 51, 57, 379080,
tzinfo=<UTC>)}, {“id” : 44, “amount” : {“value” : 45, “currency” : “usd”}, “date”: datetime.datetime(2016, 5, 8, 14,
51, 57, 379080, tzinfo=<UTC>)}, {“id” : 44, “amount” : {“value” : 45, “currency” : “usd”}, “date”:
datetime.datetime(2016, 5, 8, 14, 51, 57, 379080, tzinfo=<UTC>)}]