> how to add datepicker (available in admin) into my custom page for date
> input form field.
>
Add this to the <head> section of the page you wish to display the picker on:
<script type="text/javascript" src="{% url jsi18n %}"></script>
<script type="text/javascript" src="{{ ADMIN_MEDIA_PREFIX
}}/js/core.js"></script>
<script type="text/javascript">window.__admin_media_prefix__ = "{{
ADMIN_MEDIA_PREFIX|escapejs }}";</script>
<link href="{{ ADMIN_MEDIA_PREFIX }}/css/widgets.css"
type="text/css" media="all" rel="stylesheet" />
{{ form.media }}
Then modify your form to use the admin date picker widget:
from django.contrib.admin.widgets import AdminDateWidget
class MyForm(forms.Form):
some_date = forms.DateField(widget=AdminDateWidget())
As Kenneth said, it's easier to use jQuery's widget.
Cheers
Tom
--
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