K
K
kieko2020-11-22 22:50:31
Django
kieko, 2020-11-22 22:50:31

How to display data in a given time range?

Sort movies by number of comments

topMovie = Movie.objects.annotate(
            num_comments=Count('Comments')).order_by('-num_comments')

the Comments model has a time parameter,

how to display this field by passing the time frame
topMovie = Movie.objects.annotate(
            num_comments=Count('Comments')).order_by('-num_comments')


within the specified time frame

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-11-23
@bacon

Count and the like have a filter argument https://docs.djangoproject.com/en/3.1/ref/models/q...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question