我正在修改其他人使用django 1.8运行的代码,我想知道是否有直接替换该行
from south.db import db
使用include:
if db.backend_name == "postgres":
db.start_transaction()
db.execute_many(commands.PG_DISABLE_TRIGGERS)
db.commit_transaction()
答案 0 :(得分:2)
据我了解,替换是:
from django.db import connection
from django.db import transaction
用途:
>>> from django.db import connection
>>> connection.vendor
u'postgresql'
和
from django.db import connection
from django.db import transaction
cursor = connection.cursor()
with transaction.atomic():
cursor.executemany(commands.PG_DISABLE_TRIGGERS)