How to Disable the Django Debug Toolbar

The Django Debug Toolbar is a configurable set of panels displaying information about the current request/response. As convenient as this feature is, there might be instances where you’d like to disable it. This tutorial will guide you on how to do that.

Step 1: Verify the Django Debug Install

The first step is to check whether you have django-debug-toolbar installed. You can do this by heading over to the settings.py file in your Django project. If installed, the installed apps section should contain a line like this:

Step 2: Checking the Toolbar setting

The next step is to check for the debug toolbar’s middleware in the same settings.py file that you accessed in the first step. You’re expected to find a line like this:

Step 3: Disable/Comment the Django Debug Toolbar

To disable the Django Debug Toolbar, locate the aforementioned lines in settings.py, and comment them out using a # symbol. The following are the resulting lines after commenting:

Step 4: Save changes

After commenting out the lines, remember to save the changes in your editor. This will disable the Django Debug Toolbar in your project.

Step 5: Verify the Disablement

Finally, you need to verify that the process was successful. Trigger your Django server, and there should be no trace of the debug toolbar, confirming that the process was successful.

Full Code:

Conclusion

That’s it! You now know how to disable the Django Debug Toolbar. Keep in mind that the toolbar can be very useful for development and debugging purposes. However, it’s best to disable it during production to prevent any privacy issues.