On Sep 6, 8:40 pm, raj <rajeeshrn...@gmail.com> wrote: > Hi all, > Why can't we use the aggregate function 'max' from within save()? I > found it working to find the lot_max from among the objects filtered > by prod_date and then if lot_max is None, lot_no must be 0, else it's > just lot_max + 1. I don't know if I've misunderstood some requirement > by the way. > > Raj.
We might have a race-condition if 2 or more occurrences of the same event happens at the same time. If to processes start on about the same time then both will get the same 'max' from the database. The first that saves will be OK, the second will get a IntegrityError because it tries to use the same lot_no. Thats why something a little more is needed but you are basically right. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.