Django Integration


This guide simply points out the differences between standalone Relé and the Django integration. The basics about publishing and subscribing are described in the First Steps section.


To configure Relé, our settings may look something like:

RELE = {
    'GC_CREDENTIALS_PATH': 'photo_project/settings/dummy-credentials.json',
    'APP_NAME': 'photo-imaging',

The only major difference here is that we are using the rele.contrib.DjangoDBMiddleware. This is important to properly close DB connections.


If you plan on having your subscriber connect to the database, it is vital that the Django settings.CONN_MAX_AGE is set to 0.

Once the topic is created and our Django application has the proper configuration defined in Settings, we can start publishing to that topic.


Since the Django integration comes with python runrele command, we must name the file where we define our subscribers runrele will auto-discover all decorated subscriber methods in a defined Django app and register/create the subscriptions for us.

Subscribing follows the same method as before.


Unlike what is described in Consuming, the Django integration provides a very convenient command.

By running python runrele, worker process will autodiscover any properly decorated @sub function in the file and create the subscription for us.

Once the process is up and running, we can publish and consume.