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 <ian.tur...@gmail.com> wrote: > 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 so .dates() gives me too much information to loop > over. Any ideas? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.