Wednesday, September 23, 2015

Problem with date validator


When today's date is entered in the form  it shows a form error saying that this date (today) is in the future.
What is wrong with the validator I'm using to allow dates until today?

models.py

...
import datetime

...

class SolicitudBase(models.Model):
    ....
    fecha = models.DateField(validators=[MaxValueValidator(datetime.date.today(), message="This date can't be in the future")])
    ....


I'm using Mysql and the following settings in my django project related to timezone are commented:

#TIME_ZONE = 'EST'
#USE_TZ = True

My server (debian 7) is using US/Eastern timezone.

and right now:
root@webapp:~# date
Wed Sep 23 17:04:36 EDT 2015

Thanks in advance,
Felix.

No comments:

Post a Comment