Django 1.6 admin force db commit

64 views
Skip to first unread message

PRyan

unread,
Nov 17, 2014, 6:38:56 PM11/17/14
to django...@googlegroups.com
I'm trying to force a db commit on our users admin page. I call obj.save() then want to call sync_marketing(obj.id). When sync_marketing pulls the User object from the db by the id, it gets the data before the save, not the data afterwards.

sync_marketing is ran via celery (apply_async) and we really don't want to use countdown to delay it. i need to force the db to commit that save after I call save so then when celery pulls from the db, it is the new data. 

I've tried transaction.savepoint and savepoint_commit, no luck. If i set_autocommit to true (get_autocommit shows False) I get a "forbidden in atomic block" error.

I've tried with and without the atomic decorator. I don't know how to make it non-atomic, if that is the right path, etc.

Any suggestions would be appreciated. 
Thanks!

PRyan

unread,
Nov 17, 2014, 6:39:20 PM11/17/14
to django...@googlegroups.com
Sorry. I am trying this in model_save().

Collin Anderson

unread,
Nov 20, 2014, 9:32:17 PM11/20/14
to django...@googlegroups.com
Hi,

Yes, I think the entire admin view is wrapped in @atomic, so I don't think it's possible to end the transaction before the view finishes. Maybe you could somehow handle it in a middleware?

Collin
Reply all
Reply to author
Forward
0 new messages