I have this code:
q = MyModel.objects.order_by(\'-value1\').annotate(
res=ExpressionWrapper(
(F(\'value1\') / F(\'value2\')),
Unfortunately the ORM F('value1') / F('value2') operation is executed on the database side, therefore if both fields declared as integer you will definitely get the integer result. In Django 1.11.7 you could simply cast one of the F() expression to decimal like this:
qs = (
MyModel.objects
.annotate(
res=ExpressionWrapper(
F('value1') * 1.0 / F('value2'),
output_field=FloatField(),
),
)
)