How can I overwrite a model.save() method to write every SQL code it generates on a text file?
I am working with PostgreSQL, and it would also work if I did this on a database level (write every SQL code that changes a table on a text file).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can see the raw queries with
django.db.connection.queries. More info here.So examine that object in your save method and write the newest query to a file.