0

I am writing a Django web app and I'm having a problem with writing test method for my model and I hope you will be able to help me with it.

I created a model:

class Animal(models.Model):
    date_born = models.DateTimeField('date_born', validators=[MaxValueValidator(limit_value=timezone.now())])

New Animal instance should not be created if date_born is set to future date. I am trying to write a test in tests.py to validate if model with future date is not being created but I am not sure how to do it. Could you advise me?

  • This should help you: https://stackoverflow.com/questions/3642892/calculating-if-date-is-in-start-future-or-present-in-python/3642942 – FLAK-ZOSO Jan 23 '22 at 19:22

0 Answers0