Hi Collin, Am 05.11.2015 um 16:36 schrieb Collin Anderson:
If you're just updating one field, this _might_ work for you:
Why just one?
| try: TestMonthModel.objects.create(jahr=Jahr,monat=Monat)# create() uses force_insert. exceptIntegrityError: pass # It already exists. No Problem. # ... calculate some things. TestMonthModel.objects.filter(jahr=Jahr,monat=Monat).update(value=new_value) |
It's a nice idea, and I'll have to think more about it, but I guess that while this forces two parallel accesses to work with the same single instance, they can still both enter the calculation step, whose side effects may be hard to foresee in this context. Both will eventually also update the instance at the end, possibly with different results… I'll have to think more about this. ;-)
Best regards, Carsten -- 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+unsubscr...@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/563BBF7A.50506%40cafu.de. For more options, visit https://groups.google.com/d/optout.