This is regarding how to use a jQuery date picker
in a django powered site.
models.py
is
from django.db import models
class holidaytime(models.Model):
holiday_date = models.DateField()
I am using jquery datepicker
.
I am using a model form
and created text field
for displaying date sucessfully.
But failed to show a datepicker icon. I am using Django model forms.
You can use Bootstrap-datetimepicker (not datepicker), here is an example:
add class/id to your datetime fields by using widget:
Add the script to your template/html file: (NOTICE the format, it's import to use the same format of the Django)
You can use
widget
to pass aclass
to the form when it will be rendered in the html. Then thatclass
will be read byjavascript
to render thedatepicker
function.Here is an example:
... or through the
widgets
attribute in the Meta class when using ModelForm:Now in template: