我有一个日志模型 的 models.py
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字段的每日总计数。怎么能在django中实现呢?
答案 0 :(得分:0)
Log.objects.filter(pub_date=datetime.date.today()).count()
。这应该工作