Re: DateField widget, ModelForm and javascript

2008-04-22 Thread Guillaume Lederrey

2008/4/22 Peter Melvyn <[EMAIL PROTECTED]>:
>
>  On 4/21/08, Rishabh Manocha <[EMAIL PROTECTED]> wrote:
>
>  >  I'd be interested in knowing how to get it to show up too (what JS/CSS
>  >  files need to be added, whether there is some setting we can use in
>  >  the python code itself or do we have to print out each field
>  >  independently and insert the appropriate code for the picker etc.).
>
>  Date/Time pickers are bound via widget's class names vDateField and
>  vTimeField, hence you need to define them in your form definition.

That's the kind of solution I was thinking about. I actually would
like all of my DateFields to have a calendar widget. Is it possible to
register a custom Date widget as the default widget used by ModelForm
? Being able to create the Forms from the Models is a great
simplification for all the simple UI. It gets a bit less simple if all
those forms have to be customized to include a CSS class ...

Thank you for your help !

  MrG



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: DateField widget, ModelForm and javascript

2008-04-22 Thread Peter Melvyn

On 4/21/08, Rishabh Manocha <[EMAIL PROTECTED]> wrote:

>  I'd be interested in knowing how to get it to show up too (what JS/CSS
>  files need to be added, whether there is some setting we can use in
>  the python code itself or do we have to print out each field
>  independently and insert the appropriate code for the picker etc.).

Date/Time pickers are bound via widget's class names vDateField and
vTimeField, hence you need to define them in your form definition.

Then you have to include JavaScript files in your template:
- core.js
- calendar.js
- datetimeshortcuts.js

The last one looks for widgets having related class names in rendered
HTML code and inserts required elements&links into DOM in run-time.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: DateField widget, ModelForm and javascript

2008-04-21 Thread Rishabh Manocha

AFAIK that JS date picker is only available in the admin interface.
rendering a form as {{ my_form}} does not print that date picker
either.

I'd be interested in knowing how to get it to show up too (what JS/CSS
files need to be added, whether there is some setting we can use in
the python code itself or do we have to print out each field
independently and insert the appropriate code for the picker etc.).

Best,

R

On Mon, Apr 21, 2008 at 9:46 PM, Guillaume Lederrey
<[EMAIL PROTECTED]> wrote:
>
>  Hello !
>
>  I have a model that I try to edit with a ModelForm. This model has a
>  DateField property. I render the form in my template with a simple :
>
>  {{ form.as_p }}
>
>  I expected the DateField to be displayed as in the admin interface,
>  with a javascript date picker. But I only get a text field. The value
>  format is validated as a date format, so I expect the field is treated
>  as a DateField.
>
>  Is there a way to automagically get the javascript date picker, or is
>  it something I have to add manually ?
>
>  Thanks for your help !
>
>MrG
>
>  --
>  Jabber : [EMAIL PROTECTED]
>  Skype : Guillaume.Lederrey
>  Projects :
>  * http://rwanda.ledcom.ch/
>
>  >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



DateField widget, ModelForm and javascript

2008-04-21 Thread Guillaume Lederrey

Hello !

I have a model that I try to edit with a ModelForm. This model has a
DateField property. I render the form in my template with a simple :

{{ form.as_p }}

I expected the DateField to be displayed as in the admin interface,
with a javascript date picker. But I only get a text field. The value
format is validated as a date format, so I expect the field is treated
as a DateField.

Is there a way to automagically get the javascript date picker, or is
it something I have to add manually ?

Thanks for your help !

   MrG

-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---