Thursday, September 24, 2015

Re: Problem with date validator

Hi Felix,

From what I know model and form DateField are completely TIME_ZONE agnostics.

This is not the case for DateTimeField however. Is this what you're using?


Le jeudi 24 septembre 2015 15:13:01 UTC-4, felix a écrit :
El 23/09/15 17:12, felix escribió:

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?

import datetime


class SolicitudBase(models.Model):
    fecha = models.DateField(validators=[MaxValueValidator(, 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:

#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,

Thanks Simon for your suggestion.
I forgot to mention that it only happens with the present date (today) but it doesn't happen with past dates. So it makes me think it could be a time zone issue.


You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment