On Mon, 2006-07-03 at 08:54 -0700, Glenn Tenney wrote: > On Mon, Jul 03, 2006 at 07:09:35AM -0500, James Bennett wrote: > > You can also differentiate between the initial save and later updates > > by checking -- before calling the parent class' 'save' method -- > > whether the object has an ID; if it doesn't, then the object is being > > created for the first time, and if it does then it's an update to an > > existing object. > > Perhaps instead of relying on the behavor of the object's ID not > existing until it's been created, that should become a method. > something like Model.created() returning true/flase or Model.is_created > or... something...???
I can't see any real advantage in this. As Ivan shows, it's only a couple of lines of code anyway (and a more or less documented feature). The boolean test for "not created" at the moment is "if not self.pk:", which seems pretty reasonable. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---