Skip to content

Instantly share code, notes, and snippets.

@vbmendes
Created March 23, 2010 20:54
Show Gist options
  • Save vbmendes/341639 to your computer and use it in GitHub Desktop.
Save vbmendes/341639 to your computer and use it in GitHub Desktop.
from django.db import connection
from agenda.models import Evento
Evento.objects.extra(
select={
'month': connection.ops.date_extract_sql('month', 'data'),
'year': connection.ops.date_extract_sql('year', 'data'),
}).values('month', 'year').distinct()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment