On Dec 27, 2005, at 2:17 PM, Dody Suria Wijaya wrote:
One more thing that I have not seen is overrideable "prepare new
row" method. triggered to provide customized field value, just
after model instance creation. ie:
This is addressed under "Added a more powerful way of overriding
model methods, removed hard-coded _pre_save(), _post_save(), etc." on
the wiki page. You can override/extend the save() behavior::
class Person(models.Model):
first_name = models.CharField(maxlength=30)
last_name = models.CharField(maxlength=30)
def save(self):
self.first_name = 'anonymous at %s' % datetime.date.today
().isoformat()
super(Person, self).save(self)
Jacob