Skip to content

Instantly share code, notes, and snippets.

@berlotto
Created April 6, 2021 21:21
Show Gist options
  • Save berlotto/0c51b499af6adaa6544a5eacbb0fd860 to your computer and use it in GitHub Desktop.
Save berlotto/0c51b499af6adaa6544a5eacbb0fd860 to your computer and use it in GitHub Desktop.
How to print pretty Django Querysets query
import sqlparse
def pquery(qs):
# Pretty Print Queryset querys
statement = str(qs.query)
print sqlparse.format(statement, reindent=True, keyword_case='upper')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment