Re: Django Forms Date Format

2008-12-16 Thread Aldo

Thanks Karen,

Using a combination of  both the links you provided I sorted it.

I just needed to change my  form slightly
class MyForm(ModelForm):
  mydate = forms.DateTimeField(input_formats=['%d-%m-%Y'])
  class Meta:
  model = MyObject

Thanks again for pointing me the right direction.

On Dec 15, 6:24 pm, "Karen Tracey"  wrote:
> On Mon, Dec 15, 2008 at 10:55 AM, Aldo  wrote:
>
> > Still no good lars. Thanks though.
>
> http://docs.djangoproject.com/en/dev/ref/forms/fields/#datefield
>
> documents how to override the default valid date formats for input to a
> DateField.
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overrid...
>
> describes how to override the default fields created by a ModelForm.  So I
> think you want to override the field in your ModelForm and specify a
> different list of valid date input formats.
>
> Karen
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Forms Date Format

2008-12-15 Thread Karen Tracey
On Mon, Dec 15, 2008 at 10:55 AM, Aldo  wrote:

>
> Still no good lars. Thanks though.
>

http://docs.djangoproject.com/en/dev/ref/forms/fields/#datefield

documents how to override the default valid date formats for input to a
DateField.

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-field-types

describes how to override the default fields created by a ModelForm.  So I
think you want to override the field in your ModelForm and specify a
different list of valid date input formats.

Karen

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Forms Date Format

2008-12-15 Thread Aldo

Still no good lars. Thanks though.

On Dec 15, 3:44 pm, Lars Stavholm  wrote:
> Aldo wrote:
> > Yes I have tried that but still nothing - thats what lead me to
> > looking at this!
>
> Try with "USE_I18N = False" in settings.py.
> Some sort of known issue, I do believe there's
> a ticket somewhere confirming this.
> /L
>
> > On Dec 15, 3:28 pm, Lars Stavholm  wrote:
> >> Aldo wrote:
> >>> I am using django forms. I have created a model/form with 2 fields,
> >>> name and date.
> >>> Prior to saving the form i check if the form is_valid?
> >>> if form.is_valid():
> >>>     form.save()
> >>> My problem is it wants the date in the format - MM/DD/
> >>> Otherwise it will not see the form as valid - and not save.
> >>> How can i change this I want the date in the format DD/MM/
> >> Maybe setting DATE_FORMAT in settings.py could help.
>
> >>http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#date-...
>
> >> /Lars
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Forms Date Format

2008-12-15 Thread Lars Stavholm

Aldo wrote:
> Yes I have tried that but still nothing - thats what lead me to
> looking at this!

Try with "USE_I18N = False" in settings.py.
Some sort of known issue, I do believe there's
a ticket somewhere confirming this.
/L

> On Dec 15, 3:28 pm, Lars Stavholm  wrote:
>> Aldo wrote:
>>> I am using django forms. I have created a model/form with 2 fields,
>>> name and date.
>>> Prior to saving the form i check if the form is_valid?
>>> if form.is_valid():
>>> form.save()
>>> My problem is it wants the date in the format - MM/DD/
>>> Otherwise it will not see the form as valid - and not save.
>>> How can i change this I want the date in the format DD/MM/
>> Maybe setting DATE_FORMAT in settings.py could help.
>>
>> http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#date-...
>>
>> /Lars
> > 
> 



--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Forms Date Format

2008-12-15 Thread Aldo

Yes I have tried that but still nothing - thats what lead me to
looking at this!

On Dec 15, 3:28 pm, Lars Stavholm  wrote:
> Aldo wrote:
> > I am using django forms. I have created a model/form with 2 fields,
> > name and date.
>
> > Prior to saving the form i check if the form is_valid?
>
> > if form.is_valid():
> >     form.save()
>
> > My problem is it wants the date in the format - MM/DD/
> > Otherwise it will not see the form as valid - and not save.
>
> > How can i change this I want the date in the format DD/MM/
>
> Maybe setting DATE_FORMAT in settings.py could help.
>
> http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#date-...
>
> /Lars
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Forms Date Format

2008-12-15 Thread Lars Stavholm

Aldo wrote:
> I am using django forms. I have created a model/form with 2 fields,
> name and date.
> 
> Prior to saving the form i check if the form is_valid?
> 
> if form.is_valid():
> form.save()
> 
> My problem is it wants the date in the format - MM/DD/
> Otherwise it will not see the form as valid - and not save.
> 
> How can i change this I want the date in the format DD/MM/

Maybe setting DATE_FORMAT in settings.py could help.

http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#date-format

/Lars


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Forms Date Format

2008-12-15 Thread Aldo

Let me add, that my model contains this

mydate = models.DateTimeField().input_formats = ('%Y.%m.%d %H:%M:%S',)

But when i use the input_formats arg it allows my field to accept any
numeric data
eg: 2342342/42354235 is now accepted.

On Dec 15, 2:57 pm, Aldo  wrote:
> I am using django forms. I have created a model/form with 2 fields,
> name and date.
>
> Prior to saving the form i check if the form is_valid?
>
> if form.is_valid():
>     form.save()
>
> My problem is it wants the date in the format - MM/DD/
> Otherwise it will not see the form as valid - and not save.
>
> How can i change this I want the date in the format DD/MM/
>
> Please help
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django Forms Date Format

2008-12-15 Thread Aldo

I am using django forms. I have created a model/form with 2 fields,
name and date.

Prior to saving the form i check if the form is_valid?

if form.is_valid():
form.save()

My problem is it wants the date in the format - MM/DD/
Otherwise it will not see the form as valid - and not save.

How can i change this I want the date in the format DD/MM/

Please help
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---