Django Pythonbeta

Our Django integration lets you instrument individual HTTP requests by adding the dedicated middleware to your application. Please note that the Blackfire middleware supports Django 1.1 and higher.

Caution

Blackfire Django middleware has compatibility issues with the Django debug toolbar. You may consider disabling the Django debug middleware when using Blackfire.

Installation

First, add DjangoMiddleware to your MIDDLEWARE list in your Django settings. This middleware is present in the blackfire package when you install Blackfire for Python.

1
2
3
4
5
MIDDLEWARE = [
    # ...
    'blackfire.middleware.DjangoMiddleware'
    # ...
]

Then, restart your server.

Caution

The order of MIDDLEWARE is important. You should include the Blackfire middleware as early as possible in the list. However, it must come after any other middleware that encodes the response’s content, such as GZipMiddleware.

Profiling HTTP Requests

You can use the blackfire curl command to profile specific requests on your application.

1
blackfire curl http://localhost:8000/polls/1/results

You can also use one of our browser extensions for Firefox or Chrome.

Read more about profiling web applications with a browser, or profiling with the CLI.