hello django users !

I don't know how to do the right queryset, to get total mail have 
status='affecté' in the same date I used a queryset like this :

Evenement.objects.annotate(Day=TruncDay('date_Evt')).values('Day')\
   .annotate(affecte=Count('mail_item_fid',filter=Q(status='affecté')))\
   .all().order_by('Day')

but I want to get something like : 

Total mail have status 'affecté' : (for example 100)
date when the mail have status 'affecté': (for example 09/07/2020)
Day+0 : (here total mail have status 'livré' in day difference = 0)   [ I 
mean by day difference is the (day when mail have status 'livré' ) - (day 
when mail have status'affecté ' ) ]
Day + 1: (here total mail have status 'livré' in day difference = 1)
and so on 
 
I don't know if this possible to have something like this here 
 
 
here is my class : 

class Evenement(models.Model):
   EVENEMENT_CHOICES = (
       ("déposé","déposé"),
       ("reçu","reçu"),
       ("expédié","expédié"),
       ("affecté","affecté"),
       ("livré","livré"),
       ("echec de livraison","echec de livraison"),
   )
   mail_item_fid = models.ForeignKey(mail_item,on_delete=models.CASCADE, 
related_name='mail_item_fid_evenement')
   from_office = models.ForeignKey(Office,on_delete=models.CASCADE, 
related_name='office_Evt_evenement')
   date_Evt = models.DateTimeField() 
    status = models.CharField(max_length=50,choices=EVENEMENT_CHOICES)
   agent_delivery_cd = models.ForeignKey(Delivery_Agent,on_delete=models.
CASCADE,blank=True, null=True ,related_name='agent_evenement')
   def __str__(self):
       return '{}, {}, {}, {} '.format(self.mail_item_fid,self.from_office,
self.date_Evt,self.status)


can you help me out if it is possible 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/67312ced-a5a8-4c97-ac37-aa7bc46dc128o%40googlegroups.com.

Reply via email to