Skip to content

Instantly share code, notes, and snippets.

@alecthomas
Created April 18, 2013 00:51
Show Gist options
  • Save alecthomas/5408999 to your computer and use it in GitHub Desktop.
Save alecthomas/5408999 to your computer and use it in GitHub Desktop.
Django: Users joined by hour
models.User.objects.order_by('date_joined').extra({'day_joined': 'date(date_joined)', 'hour_joined': 'hour(date_joined)'}).values('day_joined', 'hour_joined').annotate(joined_count=Count('id'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment