I use Django ORM to create complex SQL queries dynamically, I want to save ---while running--- the SQL query that Django builds for future use, I have not found a proper way to do it.
As explained here there are two ways to access a query but only connection.queries
contains a valid query, and needed to set debug=True
.
Because I want to do it in the product environment, debug=True
is not really a solution for me, and I don't want to change the Django source code.
Any solution/comment can help me.
I use Django 2.2.