Skip to content

Instantly share code, notes, and snippets.

@gladson
Created January 5, 2012 03:25
Show Gist options
  • Select an option

  • Save gladson/1563556 to your computer and use it in GitHub Desktop.

Select an option

Save gladson/1563556 to your computer and use it in GitHub Desktop.
SQL gerado pela queryset a partir do atributo "query" de uma queryset - by Andrews Medina
>>> from django.contrib.auth.models import *
>>> print User.objects.all().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"
>>> print User.objects.filter(username='andrews').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"."username" = andrews
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment