3 ms·
If you only have the Django queryset and not the SQL, you can generate pseudo-sql using "print(queryset.query)". Note that this isn't valid SQL, just an approx
by Izkata 5y ago
If you only have the Django queryset and not the SQL, you can generate pseudo-sql using "print(queryset.query)".
Note that this isn't valid SQL, just an approximation, because Django doesn't generate a single SQL string, but uses the underlying library's parameterization. So you'll have to fiddle with quotes and such to get SQL you can run the EXPLAIN on that's mentioned in the other replies.