As for me I have a function registered for the post_save signal, so after saving the 1:1 object gets created. If you don't mind that the 1:1 object gets created outside of the atomic block, it should work for you, too.
On 24 Jun 2015 10:16, "Mike Dewhirst" <miked@dewhirst.com.au> wrote:
-- On 24/06/2015 4:43 PM, Mike Dewhirst wrote:
When saving a model I'm getting a TransactionManagementError - You can't
execute queries until the end of the 'atomic' block
Ticket #21540 seems fairly explicit at least where Postgres is
concerned. TransactionManagementError prevents what I want to do and I'm
not a nuclear expert.
How do I terminate the save() method code in that atomic block and then
immediately execute my queries?
I have implemented a workaround but not sure if it is the best way. Any comment appreciated ...
In the model's clean() method I test for self.pk and if true, execute the queries which previously caused the problem. This seems to work but hasn't had any testing in production.
Thanks again for any ideas
Mike
I need the save() to complete so I can get_or_create some 1:1 records
belonging to the model being saved.
Thanks
Mike
--
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/558A676C.5080202%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.
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/CACczBUK6gLS2%3D0Rts%2Bbo9VXSSjFQHtmv4ZGNpiuLHfodgH7R_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment