There is inconsistency between Django startup and PostgreSQL default commit mode.
Out of the box, Django uses PostgreSQL's default βread commitβ mode, which combines all operations into a single transaction, which ends when the db cursor goes out of scope. A problem occurs when an error occurs during this series of operations. Postgres expects you to roll back before continuing, and if you do not, psycopg2 throws an InternalError the next time it connects. If you rely on Django's autorun (the default), you're probably not going to roll back properly.
Fortunately, psycopg2 supports a different mode of operation called "autocommit" in which it does not set these transactions up. For those who come from MySQL (or try to support both), this brings mind to the world. In 1.1, they added support to expose it. Add the following settings to your settings (you need to change the syntax for 1.2 if you are in the trunk)
DATABASE_OPTIONS = { "autocommit": True, }
The discussion for Django ticket # 3460 contains details.
tmitchell
source share