我正在尝试通过Django自动化并发创建PostgreSQL索引。但是,当我尝试通过Django执行SQL时:
from django.db import connections
cursor = connections['mydb'].cursor()
cursor.execute('CREATE INDEX CONCURRENTLY some_index ON some_table (...)')
我收到错误:
DatabaseError: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
即使我使用旧的@commit_manually
装饰器或新的@atomic装饰器,我仍然会收到此错误。如何在Django中完全禁用事务?