#Getting the SQL for a Django `update` query

1 messages · Page 1 of 1 (latest)

rose sequoia
#

Is it possible to have Django provide me the generated SQL for an update query without actually executing it?
I tried the following, but I can't actually do .query at the end, because the update query is evaluated. Therefore an int is returned, representing the number of updated rows.

str(Foobar.objects.all().update(example=F("created")).query)
untold minnow
#

You can access recently run queries from the connection object. Let me see if I can find the docs

#

I think it's connection.queries

untold minnow