tarp20
tarp20

Reputation: 695

How to combine these 2 fields?

I have total Count of comments for 1 movie

comments = Comment.objects.filter(movie_id=object_id).count()

How to Count all comments in time period (start_date,end_date) I know About Q filter filter=Q(Comments__pub_date__range=( start_date, end_date))

so, how compine those two Fields and get the answer??

Upvotes: 1

Views: 43

Answers (1)

datosula
datosula

Reputation: 1586

I assume you want to count all comments for movie with id object_id.So you filter comments on pub date like this:

comments = Comment.objects.filter(movie_id = object_id, pub_date__range = (start_date, end_date) ).count()

Upvotes: 1

Related Questions