The create() method in Django creates a model instance then calls save(), which is said to trigger commit. So there should not be any difference in triggering transaction's commit.
But in reality, executing a method that creates a bunch of model instances using create() on Postgresql I am getting transaction aborted, commands ignored until end of transaction
exception. The method runs fine with non-transactional db backends. Also, when I replace the create()s with:
m = Model(attr1=..., attr2=...)
m.save()
it runs on Postgresql fine too.
Is there a difference between using save()
and create()
in the sense of transactions?
edit: create() also sets self._for_write = True
before calling save(), but I couldn't trace it to see if it has any effect on transaction behavior.
edit: example code can be found here.