Re: Django form: Allow user to insert a date in dd-mm-yyyy format and then convert in yyyy-mm-dd

2009-03-19 Thread Adi Sieker

On 18.03.2009, at 20:48, MarcoS wrote:

>
> Thanks for your replies, Koeb and Ady.
>
> Ady, if I understood I've to place the code from
>
> http://code.djangoproject.com/attachment/ticket/3672/ticket%233672--patch-test.diff
>
> to
>
> - python/site-packages/django/forms/forms.py and
> - python/site-packages/django/forms/widgets.py
>
Yes, basically.


> and then I call the form with the follow field:
>
> date = forms.DateField(widget=DateTextInput(format='d/m/y'),
> input_formats=['%d/%m/%y'])
>
> It's correct?
>

In the diff file there are some regression tests which show you how to  
use the Fields.

adi


> On 18 Mar, 13:45, Adi Sieker  wrote:
>> Hi,
>>
>> On 18.03.2009, at 13:01, MarcoS wrote:
>>
>>
>>
>>> Hi Adi, thanks for your reply!
>>
>>> I had just tried the DateField.input_formats, but the problem was  
>>> that
>>> I'm using the date admin widgets.
>>> If I specify input_formats like: '%d.%m.%y', I can't use the admin
>>> widgets 'cause it insert the date in the format: '%Y-%m-%d' (how you
>>> can see in django/contrib/admin/media/js/admin/DateTimeShortcuts.js
>>> line 239)...
>>
>> The Problem with the Admin is that the DateField doesn't respect any
>> output formats.
>> Check this ticket for a possible 
>> solution:http://code.djangoproject.com/ticket/3672
>>
>> adi
>>
>> --
>> Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
>> Freelance developer   skype:  adijsieker
>> SAP-Consultantweb:http://www.sieker.info/profile
>>openbc:https://www.openbc.com/hp/
>> AdiJoerg_Sieker/
> 
--
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   skype:  adijsieker
SAP-Consultantweb:http://www.sieker.info/profile
   openbc: https://www.openbc.com/hp/ 
AdiJoerg_Sieker/




--~--~-~--~~~---~--~~
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 form: Allow user to insert a date in dd-mm-yyyy format and then convert in yyyy-mm-dd

2009-03-18 Thread MarcoS

Thanks for your replies, Koeb and Ady.

Ady, if I understood I've to place the code from

http://code.djangoproject.com/attachment/ticket/3672/ticket%233672--patch-test.diff

to

- python/site-packages/django/forms/forms.py and
- python/site-packages/django/forms/widgets.py

and then I call the form with the follow field:

date = forms.DateField(widget=DateTextInput(format='d/m/y'),
input_formats=['%d/%m/%y'])

It's correct?

On 18 Mar, 13:45, Adi Sieker  wrote:
> Hi,
>
> On 18.03.2009, at 13:01, MarcoS wrote:
>
>
>
> > Hi Adi, thanks for your reply!
>
> > I had just tried the DateField.input_formats, but the problem was that
> > I'm using the date admin widgets.
> > If I specify input_formats like: '%d.%m.%y', I can't use the admin
> > widgets 'cause it insert the date in the format: '%Y-%m-%d' (how you
> > can see in django/contrib/admin/media/js/admin/DateTimeShortcuts.js
> > line 239)...
>
> The Problem with the Admin is that the DateField doesn't respect any  
> output formats.
> Check this ticket for a possible 
> solution:http://code.djangoproject.com/ticket/3672
>
> adi
>
> --
> Adi J. Sieker         mobile: +49 - 178 - 88 5 88 13
> Freelance developer   skype:  adijsieker
> SAP-Consultant        web:    http://www.sieker.info/profile
>                        openbc:https://www.openbc.com/hp/
> AdiJoerg_Sieker/
--~--~-~--~~~---~--~~
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 form: Allow user to insert a date in dd-mm-yyyy format and then convert in yyyy-mm-dd

2009-03-18 Thread Adi Sieker
Hi,

On 18.03.2009, at 13:01, MarcoS wrote:

>
> Hi Adi, thanks for your reply!
>
> I had just tried the DateField.input_formats, but the problem was that
> I'm using the date admin widgets.
> If I specify input_formats like: '%d.%m.%y', I can't use the admin
> widgets 'cause it insert the date in the format: '%Y-%m-%d' (how you
> can see in django/contrib/admin/media/js/admin/DateTimeShortcuts.js
> line 239)...

The Problem with the Admin is that the DateField doesn't respect any  
output formats.
Check this ticket for a possible solution: 
http://code.djangoproject.com/ticket/3672

adi

--
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   skype:  adijsieker
SAP-Consultantweb:http://www.sieker.info/profile
   openbc: https://www.openbc.com/hp/ 
AdiJoerg_Sieker/




--~--~-~--~~~---~--~~
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 form: Allow user to insert a date in dd-mm-yyyy format and then convert in yyyy-mm-dd

2009-03-18 Thread koenb

On 18 mrt, 13:01, MarcoS  wrote:
> Hi Adi, thanks for your reply!
>
> I had just tried the DateField.input_formats, but the problem was that
> I'm using the date admin widgets.
> If I specify input_formats like: '%d.%m.%y', I can't use the admin
> widgets 'cause it insert the date in the format: '%Y-%m-%d' (how you
> can see in django/contrib/admin/media/js/admin/DateTimeShortcuts.js
> line 239)...
>

Marco,

look at my solution here: 
http://groups.google.be/group/django-users/msg/50eba033580c7536

to use the admin date picker, you need to tell your widget to add the
correct attrs so the last line becomes something like this:

super(DateWidget, self).__init__(format=settings.DATE_OUTPUT_FORMAT,
attrs={'class': 'vDateField'})

good luck,

Koen
--~--~-~--~~~---~--~~
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 form: Allow user to insert a date in dd-mm-yyyy format and then convert in yyyy-mm-dd

2009-03-18 Thread MarcoS

Hi Adi, thanks for your reply!

I had just tried the DateField.input_formats, but the problem was that
I'm using the date admin widgets.
If I specify input_formats like: '%d.%m.%y', I can't use the admin
widgets 'cause it insert the date in the format: '%Y-%m-%d' (how you
can see in django/contrib/admin/media/js/admin/DateTimeShortcuts.js
line 239)...



On Mar 18, 11:53 am, Adi Sieker  wrote:
> Hi,
>
> On 18.03.2009, at 11:43, MarcoS wrote:
>
>
>
> > Hi all,
> > I'm implementing a form in django with a DateField field in forms.py.
> > My purpose is to allow a user to insert a date in european format (dd/
> > mm/) and then, obviously, convert it in the /mm/dd format to
> > let's django check if it's a valid date and save it in a db.
>
> > currently I've a javascript code that intercept the "submit command"
> > in the html form and converts the date in /mm/dd.
>
> > My ask is: It's possible to implement the convertion, not in a
> > javascript function, but directly in views.py or forms.py before
> > cleaning the date?
>
> check the DateField form widget. It allows you to specify what format  
> the date should be in.
>
> http://docs.djangoproject.com/en/dev/ref/forms/fields/#datefield
>
> adi
--~--~-~--~~~---~--~~
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 form: Allow user to insert a date in dd-mm-yyyy format and then convert in yyyy-mm-dd

2009-03-18 Thread Adi Sieker

Hi,

On 18.03.2009, at 11:43, MarcoS wrote:

>
> Hi all,
> I'm implementing a form in django with a DateField field in forms.py.
> My purpose is to allow a user to insert a date in european format (dd/
> mm/) and then, obviously, convert it in the /mm/dd format to
> let's django check if it's a valid date and save it in a db.
>
> currently I've a javascript code that intercept the "submit command"
> in the html form and converts the date in /mm/dd.
>
> My ask is: It's possible to implement the convertion, not in a
> javascript function, but directly in views.py or forms.py before
> cleaning the date?

check the DateField form widget. It allows you to specify what format  
the date should be in.

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

adi

--~--~-~--~~~---~--~~
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 form: Allow user to insert a date in dd-mm-yyyy format and then convert in yyyy-mm-dd

2009-03-18 Thread MarcoS

Hi all,
I'm implementing a form in django with a DateField field in forms.py.
My purpose is to allow a user to insert a date in european format (dd/
mm/) and then, obviously, convert it in the /mm/dd format to
let's django check if it's a valid date and save it in a db.

currently I've a javascript code that intercept the "submit command"
in the html form and converts the date in /mm/dd.

My ask is: It's possible to implement the convertion, not in a
javascript function, but directly in views.py or forms.py before
cleaning the date?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---