Skip to main content

Integration of Django with dramatiq-pg

Project description

dramatiq-pg integration for django.


  1. Install with pip

    $ pip install django-dramatiq-pg
  2. Add to your INSTALLED_APPS list in

  3. Create a Registry, and register your tasks

    from django_dramatiq_pg.registry import Registry
    tasks = Registry()
    def mytask():
  4. Configure

        "OPTIONS": {
            "url": "postgres:///mydb",
        "MIDDLEWARE": [
    DRAMATIQ_REGISTRY = 'myapp.registry.tasks'
  5. Start the worker process:

    $ dramatiq django_dramatiq_pg.worker

This worker module will auto-discover any module called ‘actors’ in INSTALLED_APPS.


In a typical dramatiq application, the Broker is configured before any tasks are registered. However, as Django is in control of the intialisation sequence, there is an issue of ordering; the actor decorator assumes the broker is already configured.

To resolve this, django_dramatiq_pg provides a Registry for your tasks, which is then bound to the Broker when Django initialises.

In your code, declare a Registry instance, and use its .actor method to decorate your task functions. Then tell django_dramatiq_pg to use your registry with the DRAMATIQ_REGISTRY setting.

If you do not specify one, django_dramatiq_pg will create one on start.

The registry can be accessed as the .registry attribute on the django_dramatiq_pg App instance.



A dict of options to pass when instantiating the broker.


Arguments to pass to the Broker.


A list of middleware classes to be passed to the broker.

These can either be import strings, or instances.


Default: None

Import path for encoder class.


Default: ‘actors’

Name of module use to auto-discover actors in INSTALLED_APPS.


Import path for the task Registry instance.

This should refer to an instance of django_dramatiq_pg.registry.Registry.

This resolves the chicken/egg problem of declaring tasks before the broker is configured.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-dramatiq-pg-1.3.2.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

django_dramatiq_pg-1.3.2-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page