chantheman
chantheman

Reputation: 5296

django SQL Console

I am trying to debug a piece of SQL that is coming back incorrectly. I am not sure if django or mysql is handling it wrong so I want to run it through a django console.

Is there a way to set this up?

Thanks in advance.

Upvotes: 9

Views: 11963

Answers (2)

Mike Ramirez
Mike Ramirez

Reputation: 10970

manage.py dbshell or manage.py shell shell being going into the python interpreter loading your project settings, dbshell putting you in the database cli client. django.db.queries holds the queries that django creates. bigmattyh's suggestion of debug toolbar is a good one, but not interactive.

Upvotes: 16

Matt Howell
Matt Howell

Reputation: 15966

A good place to start is to install the django debug toolbar in your project. It provides an unobtrusive interface that gives you access to the SQL queries so you can hunt down what's happening at that level.

Upvotes: 1

Related Questions