django-transaction-signals icon indicating copy to clipboard operation
django-transaction-signals copied to clipboard

django 1.6?

Open wingyiu opened this issue 11 years ago • 6 comments

Django’s default transaction behavior¶ Django’s default behavior is to run in autocommit mode. Each query is immediately committed to the database. See below for details.

Django uses transactions or savepoints automatically to guarantee the integrity of ORM operations that require multiple queries, especially delete() and update() queries.

Changed in Django 1.6: Previous version of Django featured a more complicated default behavior.

Is these codes still work in django 1.6?

wingyiu avatar Jan 10 '14 06:01 wingyiu

+1

sthzg avatar Mar 17 '14 15:03 sthzg

Sorry to leave you hanging here - I haven't had time to maintain this project in a while.

I haven't tested the signals in Django 1.6 and wouldn't be surprised if they break (this whole thing is a blatant monkey-patch, so it's extra sensitive to breakage due to version upgrades and changes in internal APIs). I'm finally on an upgrade track for the main project I'm working on these days to bring it up to 1.6, so I'll probably have more of a chance to hack on this than I have. Until then, any patches are definitely appreciated, and I'll make it a priority to incorporate them.

davehughes avatar Mar 17 '14 17:03 davehughes

Thanks for your reply. I had no luck with testing them. First I tried with the original gist, then this module. The first approach by just registering the post_commit signal didn't throw an exception, but it didn't seem to catch the signal (function has never been called)

The second approach using defer resulted in an exception pointing out to this passage in the django transaction documentation:

During the deprecation period, it’s possible to use atomic() within autocommit(),
commit_on_success() or commit_manually(). However, the reverse is forbidden, 
because nesting the old decorators / context managers breaks atomicity.

https://docs.djangoproject.com/en/1.6/topics/db/transactions/#api-changes

sthzg avatar Mar 18 '14 08:03 sthzg

Did you find a solution to this problem by now?

dmr avatar Apr 24 '14 14:04 dmr

Not yet, sorry.

davehughes avatar Apr 24 '14 18:04 davehughes

django-transaction-hooks provided a solution for me https://github.com/carljm/django-transaction-hooks/ because it supports Django 1.6

dmr avatar Apr 26 '14 04:04 dmr