Django Pythonbeta

Our Django integration lets you instrument individual HTTP requests by adding a dedicated middleware to your application. Please note that Blackfire 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 MIDDLEWARE in your Django settings. This code 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 Blackfire as early as possible in the list. However, it must come after any other middleware that encodes the response’s content, such as gzip encoders.

Profiling HTTP Requests

You can use the blackfire curl command to profile specific requests:

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.