Problems with a slow running Django project?

Are you having trouble with the performance of your Django project? Pages loading slowly and can’t figure out why? Try using the Django-Debug-Toolbar!

Django uses an object relational mapper, meaning database queries are often carried out in the background, which can result in inefficient queries being made to the database. This can easily happen with complex models, such as those with many-to-many relationships, and can result in multiple queries being made to retrieve just a single object’s attributes.

These kinds of queries can easily mount up, hitting the database with hundreds or thousands of queries simultaneously, which can seriously affect the performance of your web application.

The Django-Debug toolbar helps developers optimise their code and reduce the strain on the database by showing useful information about queries being run

In the Django-Debug-Toolbar’s SQL pane you can easily see:

  • The number of queries being run
  • The total time taken to run them all
  • The time each query took to run
  • The SQL for each query

The Django-Debug-Toolbar can also give you a handy overview of the following debug information:

  • Settings – see the current value of any settings
  • HTTP Headers – see what the server is sending to the browser
  • GET/POST/cookie/session variables – see what data is being passed to the server
  • Cache calls –  see what items are cached
  • Signals –  see what other scripts are being triggered and their arguments and receivers
  • Templates and context used –  if using multiple templates and complex context construction

This information can be used to identify troublesome queries that take longer to execute than they should do, and lets you know whether the changes you're making are helping, or making the problem worse!

Note that the Django-Debug-Toolbar itself will affect the load time of the page as well, so if you are testing the site's performance you should disable the Django-Debug-Toolbar first to get a realistic result.

You can get the Django-Debug toolbar here: http://pypi.python.org/pypi/django-debug-toolbar


Want to know more?

Find out about our technical consulting and advisory services.

Speak with one of our experts


www.mercurytide.co.uk would like to store information (cookies) on your computer. By continuing to use this site, you consent to this.
More info