V
V
vdm_mar2018-08-11 13:34:58
Django
vdm_mar, 2018-08-11 13:34:58

What is the best way to use data aggregation of two fields?

There is a number of likes and a number of dislikes. Posts are displayed on the top feed by the difference between likes (the 'like' field) and dislikes (the 'dislike' field). Which is better: 1) annotate(count=F('like')-F('dislike')).order_by("-count") or 2) add a third count field, override save, write the difference to count, and then output by count ?
The site is the first in life, there will be few requests, but I want to know how best for the future.
Thank you!

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