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开发者_Go百科 to run it through a django console.
Is there a way to set this up?
Thanks in advance.
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.
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.
精彩评论