Thursday, November 20, 2014

Re: Django 1.6 admin force db commit

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


On Monday, November 17, 2014 6:38:56 PM UTC-5, PRyan wrote:
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!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/361b85e0-0448-4ac8-9c53-22645cda7586%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment