I'm learning python, hence this is probably an obvious solution for some, but I am trying to create a class that, whenever created, has a test
field with a date value of three months from now.
My class is as follows:
class Something(models.Model):
test = models.DateTimeField(default=self.get_date())
def get_date(self):
today = datetime.date.today()
return today + relativedelta(months=1)
I thought that I could define it as a function and then call it to set the date. Can someone advise what's wrong here? Any links to relevant documentation would also be appreciated, thank you.