I am trying to do a basic date calculation in a save model in django, see below code:
class Purchase(models.Model): purchase_date = models.DateField() purchase_place = models.CharField(verbose_name='Place of Purchase', max_length=255) purchaseCategory = models.ForeignKey(PurchaseCategory, verbose_name='Purchase Category') cost = models.DecimalField(max_digits=11, decimal_places=2) warranty_period_number = models.IntegerField() warranty_period_type = models.CharField(max_length=255, choices=(('m', 'Month(s)'), ('y', 'Year(s)'))) warranty_end_date = models.DateField(editable=False) scan = models.CharField(max_length=255) alerts = models.BooleanField(verbose_name='Receive Email Alerts?') user = models.ForeignKey('auth.User', editable=False) created = models.DateTimeField(editable=False, auto_now_add=True) modified = models.DateTimeField(editable=False, auto_now=True)
I thought the following would work, but no luck .. these are errors with:
'datetime.date' object has no attribute 'timedelta'
Can someone point in the right direction to do what I'm trying to do?
Cheers, Ben
source share