Wednesday, February 29, 2012

DateField - format in Django 1.3.1

Hi,

I saw there was some problems in the format which is rendered,
validated and stored using a DateField in a form, and in a model. Are
they still unresolved in 1.3.1 versio?, it's not working for me ....

My form:
32 class EventForm(forms.Form):
33 name =
forms.CharField(label=_('name'),max_length=100,required=True)
34 startDate = forms.DateField(input_formats=['%d/%m/
%Y'],label=_('sta rtDate'),
required=False,initial=datetime.date.today)
35 endDate = forms.DateField(input_formats=['%d/%m/
%Y'],label=_('endDa te'),
required=False,initial=datetime.date.today)


My model:
34 class Event(models.Model):
35 eventID = models.AutoField(primary_key=True)
36 name = models.CharField(max_length=100,null=False,blank=False)
38 startDate = models.DateField('%d/%m/
%Y',null=True,blank=False,default=date.today)
39 endDate = models.DateField('%d/%m/
%Y',null=True,blank=False,default=date.today)

And the POST message:
POST:<QueryDict: {u'startDate': [u'01/01/2012'], u'endDate':
[u'31/12/2012'], u'name': [Year 2012']}>,

The render is properly drawn.

Tanks a lot,
Xavi

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

No comments:

Post a Comment