Friday, January 30, 2015

Re: When do I have to call save() on a Model Instance?

> Den 29/01/2015 kl. 19.40 skrev Tobias Dacoir <falc410@gmail.com>:
>
> Thanks for answering all my questions.
>
> So it's perfectly save to call the save method at a later time? As long as I keep the object and a pointer to it in memory I can freely modify it in several Functions before finally calling save at some point in time?

This depends on your requirements. If there's a chance that another thread has modified the same object in the database from the time you fetch the data and until you call save(), then it's not necessarily safe. This would depend on your use of transactions, whether the data has been submitted from a form etc.

You should audit your code for these things if race conditions are a concern to you.

Erik

--
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/D46AC3C3-B2A3-4D09-8C9A-370AC0367DFB%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment