【发布时间】:2013-08-27 05:06:22
【问题描述】:
我想从 django 查询中提取一些特定的列
models.py
class table
id = models.IntegerField(primaryKey= True)
date = models.DatetimeField()
address = models.CharField(max_length=50)
city = models.CharField(max_length=20)
cityid = models.IntegerField(20)
这是我目前用于查询的内容
obj = table.objects.filter(date__range(start,end)).values('id','date','address','city','date').annotate(count= Count('cityid')).order_by('date','-count')
我希望有一个类似这样的SQL查询
select DATE(date), id,address,city, COUNT(cityid) as count from table where date between "start" and "end" group by DATE(date), address,id, city order by DATE(date) ASC,count DESC;
【问题讨论】:
标签: django django-models django-queryset