Django Filter Query

Saturday, July 5, 2014

I want to get the count of all packets which have status = 'open' from the last 100 packets scanned.

Currently I do a sequential search,ie

packet_obj = Packets.objects.all().oreder_by('-time')[:100] # getting the last 100 packets

for packets in packet_obj:
if packets.status == 'open' : count += 1 # comparing the status

Is there a direct single query to get this count?