Wednesday, February 12, 2020

Re: AutoField & auto-incrementing

On 12/02/2020 6:54 pm, Mike Dewhirst wrote:
> def save(self, *args, **kwargs):
>     self._pre_save()    # stuff to be computed pre-save
>     super().save(*args, **kwargs)
>     self._post_save()   # stuff to be done after the save

Also of occasional value ...

def save(self, *args, **kwargs):
    whatever = self._pre_save()    # returns something needed by
_post_save()
    super().save(*args, **kwargs)
    self._post_save(whatever)      # gets input across the super ()
boundary

Cheers

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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c012d154-fb3a-046a-5e48-0a9d838e2119%40dewhirst.com.au.

No comments:

Post a Comment