F
F
FulTupFul2018-09-30 22:31:49
Django
FulTupFul, 2018-09-30 22:31:49

Find the maximum difference between two fields in one query?

There is a model:

class Ground(models.Model):
    current_cost = models.DecimalField(_("Текущая стоимость"), max_digits=21, decimal_places=2, blank=True, null=True)
    cost_intermediate = models.DecimalField(_("Ожидаемая стоимость"), max_digits=21, decimal_places=2, blank=True,
                                            null=True)

How to get the maximum difference from these two fields?
It turned out to be done using aggregate, but it only returns the maximum difference, and not a queryset on this object

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question