DateTimeField doesnt get future date.

74 views
Skip to first unread message

Recep KIRMIZI

unread,
Dec 12, 2010, 4:29:37 PM12/12/10
to django...@googlegroups.com
Hi i have a model which has a datetime field like

pub_date = models.DateTimeField("Etkinlik Tarihi")

this model is written to organize some events in a cafe. when i m trying to create some events from the admin panel. if i choose today and now from the date widget in admin; it works. if i choose a past date it works too. But if i choose a future date, it says. Enter a valid date. i dont know is it a bug about django or did i do sth. wrong in my model. here is my whole model.

p.s.: i'm using django trunk on my server

(InteractiveConsole)
>>> import django
>>> django.VERSION
(1, 3, 0, 'alpha', 1)
>>>
------------------------------------------------------------------
#!/usr/bin/python
#-*- coding: utf-8 -*-
from django.db import models
from photologue.models import Photo

class Etkinlik(models.Model):
name = models.CharField("Etkinlik Adı", max_length=100)
text = models.TextField("Etkinlik Metni", max_length=2000)
foto = models.ForeignKey(Photo)
pub_date = models.DateTimeField("Etkinlik Tarihi")
is_active = models.BooleanField("Aktif", default=True)

class Meta:
get_latest_by = "pub_date"
verbose_name = "Etkinlik"
verbose_name_plural = "Etkinlikler"

def __unicode__(self):
return u"%s - %s" %(self.name, self.text)

def get_absolute_url(self):
return "/etkinlik/%i/" % self.id
------------------------------------------------------------------


--
Yours,
Recep KIRMIZI <rkir...@gmail.com>

Sam Lai

unread,
Dec 12, 2010, 9:33:37 PM12/12/10
to django...@googlegroups.com
Sounds odd. What is the future date you're entering? Are you sure your
system has the right date format set, e.g. you're not entering a
MM/dd/yyyy date when the system is expecting a dd/MM/yyyy date or vice
versa?

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

Recep KIRMIZI

unread,
Dec 12, 2010, 9:45:24 PM12/12/10
to django...@googlegroups.com
On Mon, 13 Dec 2010 13:33:37 +1100
Sam Lai <samue...@gmail.com> wrote:

> Sounds odd. What is the future date you're entering? Are you sure your
> system has the right date format set, e.g. you're not entering a
> MM/dd/yyyy date when the system is expecting a dd/MM/yyyy date or vice
> versa?
>

This is what i tried just now:
Date: 23/12/2010
Time: 12:00:00
i've set these values from the datepicker applet in admin panel.

now i recognized sth. I guess it's expecting as u said. MM/dd/yyyy
bec. i've chosen a past date and it works. Coinsidencely today is 13rd. of December. so the days before this date in this month are like 11/12/2010 so it 's ok both day or month less then 12 :)
i tried past month. 25th it failed again. how can i change the default datetime format?


--
Recep KIRMIZI <rkir...@gmail.com>

Sam Lai

unread,
Dec 12, 2010, 10:23:06 PM12/12/10
to django...@googlegroups.com
On 13 December 2010 13:45, Recep KIRMIZI <rkir...@gmail.com> wrote:
> On Mon, 13 Dec 2010 13:33:37 +1100
> Sam Lai <samue...@gmail.com> wrote:
>
>> Sounds odd. What is the future date you're entering? Are you sure your
>> system has the right date format set, e.g. you're not entering a
>> MM/dd/yyyy date when the system is expecting a dd/MM/yyyy date or vice
>> versa?
>>
> This is what i tried just now:
> Date: 23/12/2010
> Time: 12:00:00
> i've set these values from the datepicker applet in admin panel.
>
> now i recognized sth. I guess it's expecting as u said. MM/dd/yyyy
> bec. i've chosen a past date and it works. Coinsidencely today is 13rd. of December. so the days before this date in this month are like 11/12/2010 so it 's ok both day or month less then 12 :)
> i tried past month. 25th it failed again. how can i change the default datetime format?

Windows or Linux?

Recep KIRMIZI

unread,
Dec 12, 2010, 11:07:49 PM12/12/10
to django...@googlegroups.com
On Mon, 13 Dec 2010 14:23:06 +1100
Sam Lai <samue...@gmail.com> wrote:

> On 13 December 2010 13:45, Recep KIRMIZI <rkir...@gmail.com> wrote:
> > On Mon, 13 Dec 2010 13:33:37 +1100
> > Sam Lai <samue...@gmail.com> wrote:
> >
> >> Sounds odd. What is the future date you're entering? Are you sure your
> >> system has the right date format set, e.g. you're not entering a
> >> MM/dd/yyyy date when the system is expecting a dd/MM/yyyy date or vice
> >> versa?
> >>
> > This is what i tried just now:
> > Date: 23/12/2010
> > Time: 12:00:00
> > i've set these values from the datepicker applet in admin panel.
> >
> > now i recognized sth. I guess it's expecting as u said. MM/dd/yyyy
> > bec. i've chosen a past date and it works. Coinsidencely today is 13rd. of December. so the days before this date in this month are like 11/12/2010 so it 's ok both day or month less then 12 :)
> > i tried past month. 25th it failed again. how can i change the default datetime format?
>
> Windows or Linux?
>

i m using linux, and i fixed it by adding

USE_L10N = True

in my settings.py

Reply all
Reply to author
Forward
0 new messages