Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6870845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:43:58+00:00 2026-05-27T03:43:58+00:00

I have a Django-based webapp that is using PostgreSQL as the backend via psycopg2.

  • 0

I have a Django-based webapp that is using PostgreSQL as the backend via psycopg2. Right now we’re on postgres 8.4.x but will move to 9.1.x in the future. We’re using the current stable release of Django (1.3.1).

I want to enable stricter transaction isolation (as per the postgres docs) at either the REPEATABLE READ or SERIALIZABLE levels. From the psycopg2 source, the ones available are:

"""Isolation level values."""
ISOLATION_LEVEL_AUTOCOMMIT          = 0
ISOLATION_LEVEL_READ_UNCOMMITTED    = 1
ISOLATION_LEVEL_READ_COMMITTED      = 2
ISOLATION_LEVEL_REPEATABLE_READ     = 3
ISOLATION_LEVEL_SERIALIZABLE        = 4

Unfortunately, Django 1.3.1’s psycopg2 backend implementation of _set_isolation_level() includes assert level in (0, 1) which seems to preclude using this method to set the isolation level as high as I want right now.

In a recent commit to Django’s trunk, it’s nice to see that this restriction has been relaxed to allow levels up to 4, however, there still does not appear to be an option via the normal Django settings to actually indicate to the backend that you want a higher isolation level than ISOLATION_LEVEL_READ_COMMITTED. In other words, whilst _set_isolation_level() will now accept a level up to 4, there is no config-based way to actually cause it to be called with 4 as the argument.

Questions:

  • Assuming I was willing to start using Django’s devel version to get this change, what would be the correct / recommended way to call _set_isolation_level() manually given that there is no config option that will result in it being called with the isolation level I want?

  • Assuming I’m not willing to use Django’s devel version, what is the recommended way to pass the desired isolation level through to psycopg2 using Django 1.3.1?

  • Do both current and future versions of Django make it hard to specify these higher isolation levels because they cause huge problems in practice? (i.e. should I be doing this at all?) Keep in mind, our app has relatively low DB throughput with large, infrequent transactions with an extremely high desire for consistency.

Thanks in advance for any suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:43:59+00:00Added an answer on May 27, 2026 at 3:43 am

    The easiest and most compatible way of doing this would be to write your own DB adapter that inherits from django’s default and overrides the methods so that you set your own isolation level.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Django-based webapp that imports a Cocoa framework via PyObjC. The Cocoa
I have a Django form that uses a different number of fields based on
I have a website tracked using Google Analytics. It is a Django-based website, so
I'm creating a Django powered website that will have numerous applications (Blog, Shop, Portfolio,
My django based website will have 3 seperate menus. The items of first one
I have a Django based CMS that uses Django's sites framework and Nginx/Apache/mod_wsgi virtual
I have a Django-based web application that is required to send a confirmation email
In our web application (django based, with solr backend) we have some checkboxes with
I have a Django app running on Windows (via Apache + mod_wsgi) that's CPU-bound.
I've got a Django-based site that allows users to register (but requires an admin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.