Skip to content

Instantly share code, notes, and snippets.

@tmc
Forked from jacobian/gist:590292
Created September 21, 2010 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmc/590294 to your computer and use it in GitHub Desktop.
Save tmc/590294 to your computer and use it in GitHub Desktop.
In [1]: from django.contrib.auth.models import User
In [2]: import datetime
In [3]: qs = User.objects.filter(date_joined__lte=datetime.datetime.now)
In [4]: print qs.query
------> print(qs.query)
SELECT "auth_user"."id", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."date_joined" <= 2010-09-21 13:58:50.361784
In [5]: print qs.query
------> print(qs.query)
SELECT "auth_user"."id", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."password", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."is_superuser", "auth_user"."last_login", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."date_joined" <= 2010-09-21 13:58:50.361784
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment