5

I would like to automatically create an expire date in my model based on the create date. Say 60 days?

 class Something ( models.Model ):

    created = models.DateTimeField ( auto_now_add = True )
    expires = models.DateTimeField (  )

What is the best way to accomplish this?

Thanks!

diogenes
  • 1,865
  • 3
  • 24
  • 51
  • If you were going to always do it against the current day, then you could make a function that computes that 60 day diff dynamically, and put that function pointer in the `default=func_name`. – jheld Jan 30 '18 at 03:33
  • 1
    please check this answer https://stackoverflow.com/a/12654998/2955584 – rsb Jan 30 '18 at 08:01

0 Answers0