Re: Selecting distinct months from a QuerySet

2011-05-19 Thread Scott Gould
I'd either add a manager with a method that did the query you describe in SQL, or (if you're wanting the whole queryset anyway) just calculate it via: months = list(set(x.datetime_field.month for x in queryset)) months.sort() On May 19, 1:03 am, Ian Turner wrote: >

Selecting distinct months from a QuerySet

2011-05-18 Thread Ian Turner
Hi, I would like to get a distinct list of months from a datetime field on an already defined QuerySet. SQL that I would use manually to get distinct from all records on the model. SELECT DISTINCT MONTH(`some_datetime_field`) as `month` FROM `some_model` ORDER BY `month` I don't need the year