Yos Riady software craftsman 🌱

Effective Django Debugging with runserver_plus

Django Extensions is a collection of custom extensions for the Django Framework. These include management commands, additional database field, admin extensions and much more. One command that I’d like to highlight in this post is runserver_plus, which makes debugging a lot simpler when you’re trying to figure out what in the world is wrong in your code.

Let’s try it out in our command line:

pip install django-extensions
pip install ipython ipdb
pip install Werkzeug
./manage.py runserver_plus settings.py

In your settings.py:

INSTALLED_APPS = (
    ...
    'django_extensions',
)

First, you will need to install IPython, ipdb, Werkzeug, and django_extensions. You should then add django_extensions to your INSTALLED_APPS in your settings.py. Now that you have everything installed, you can use additional management commands such as shell_plus and runserver_plus.

Let’s take a look of this in the browser. There’s a normal series of errors, but the color schemes are different. Notice that there is an icon terminal in the error snippet. Clicking it opens a prompt and you can start typing.

Django Debugger Console

Basically, you have a console in your browser, which makes basic requests to the command line and returns the result. Think of this as an ipdb breakpoint and each of these points of the code.

Django Debugger Console

This is very powerful because it can make debugging a lot simpler, instead of having to manually put import ipdb; ipdb.set_trace().

Happy debugging!

Author

Yos is a software craftsman based in Singapore.

📬 Subscribe to my newsletter

Get notified of my latest articles by providing your email below.


Going Serverless book

Interested to find out more about serverless? Going Serverless teaches you how to build scalable applications with the Serverless framework and AWS Lambda. You'll learn how to design, develop, test, deploy, and secure Serverless applications from planning to production.

Learn More →