2013-11-21 74 views
0

每日計數我有一個日誌模型 models.py查詢在Django

class Log(models.Model): 
    module   = models.CharField(null=False, blank=False,default=None, max_length=20) 
    mobile   = models.CharField(null=False, blank=False,max_length=15) 
    incoming_text = models.TextField(null=False, blank=False,) 
    outgoing_text = models.TextField(null=False, blank=False,) 
    shortcode  = models.CharField(null=False, blank=False, max_length=6) 
    network  = models.CharField(null=True, blank=False, max_length=15) 
    user   = models.CharField(null=True, blank=False, max_length=15) 
    created_on  = models.DateTimeField(auto_now_add=True, null=False, blank=False) 
    campaign  = models.CharField(null=False, blank=False, max_length=30) 

現在我不得不產生Django的查詢,從而created_on場的基礎上,每天的總次數爲reqquired。我怎麼能在django中實現它?

回答

0

Log.objects.filter(pub_date=datetime.date.today()).count()。這應該工作