'How to add a given number of days to a django DateTimeField
I have a model with a field containing a DateTimeField and a function to calculate a return date based on this DateTimeField. How would I add a given number of days to this????
class MyModel(models.Model):
startdate = models.DateTimeField(auto_now_add=True)
enddate = models.DateField()
def save(self)
self.enddate = self.startdate + datetime.timedelta(days=5)
super(MyModel, self).save(*args, **kwargs)
This however does not work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
