1👍
✅
From the documentation:
Django supports the use of addition, subtraction, multiplication, division and modulo arithmetic with F() objects, both with constants and with other F() objects.
Logarithms aren’t a supported operation, so there’s no way to get log(d*e)
into an update call. You’ll have to do that in Python at some point, or by using a direct SQL update. Or by using a database view containing LOG(d)
and LOG(e)
as columns instead of the default table.
The rest of it you can do:
Data.objects.update(x=(F('b') * 100 + F('e') * F('e') * F('f')), y=(F('b') + (F('e') * F('e')) / F('f'))
I understand that that doesn’t help much without the logarithms, but I’m including it to demonstrate the use of the arithmetic on F objects.
Source:stackexchange.com