I have database created by Django model, where status
and id
and username
are the fields of the table Messages
.
I need to count the number of rows where status value= 0
for a particular username
.
This is my incomplete code:
Message_me = Messages.objects.get(username='myname')
Try this code:
Message_me = Messages.objects.filter(username='myname', status=0).count()