from datetime import timedelta
# custom save model
def save(self, *args, **kwargs):
# figure out warranty end date
if self.warranty_period_type == 'm':
self.warranty_end_date = self.purchase_date + timedelta(days=self.warranty_period_number*31)
else:
self.warranty_end_date = self.purchase_date + timedelta(days=self.warranty_period_number*365.2425)
super(Purchase, self).save(*args, **kwargs)
def save(self, *args, **kwargs):
if self.id:
print('updating')
else:
print('creating')
super(Post, self).save(*args, **kwargs)
def save(self, *args, **kwargs):
if self.title == “i dont like coding”:
return # instance not save
self.slug = slugify(self.title)
super(Post, self).save(*args, **kwargs)