[Django]-Enable dirty reads for single transaction in Django

5👍

Based on this similar question and comments to this answer, you could try using two database conexions with different isolation levels.

The following code is from the linked answer:

DATABASES = {
    'default': {
        'NAME': 'app_data',
        'ENGINE': 'django.db.backends.postgresql',
        'USER': 'postgres_user',
        'PASSWORD': 's3krit',
    },
    'serializable': {
        'NAME': 'app_data',
        'ENGINE': 'django.db.backends.postgresl',
        'USER': 'postgres_user',
        'PASSWORD': 's3krit',
        'OPTIONS': {
            'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE,
        },
    },
}

You can change it to fit your needs (maybe use READ UNCOMMITED instead of SERIALIZABLE) and then let us know if that solves your problem.

👤Ralf

Leave a comment