Hello,

I wanted to add a javascript calendar (like the one you have in
Django's admin) to a date textbox in a form.
I found this post, which says how to do it:
http://groups.google.com/group/django-users/browse_frm/thread/3328829f1ed7f788/27557f8194b84134

I thought I might share with you how I did it - I think that it's
simpler than what's described there.

To add the calendar, you only need to:

1. Make sure that the admin interface is enabled.
2. Add this to the <head> element in your HTML template:

<link rel="stylesheet" type="text/css" href="/media/css/widgets.css" /
>
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="/media/js/core.js"></script>
<script type="text/javascript" src="/media/js/calendar.js"></script>
<script type="text/javascript" src="/media/js/admin/
DateTimeShortcuts.js"></script>

Note that this assumes that your admin media sits in "/media". If it's
not the case, you need to replace "/media" with your admin media path.

3. Add an attribute class="vDateField" to your <input type="text">
element.
If you're using the newforms library, you can do it by using a line
like this in your form definition:
    date =
forms.DateField(widget=forms.TextInput(attrs={'class':"vDateField"}))

Have a good day,
Noam


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to