I have some inconvenience when I try render django-bootstrap-datepicker-plus widget according to this answer. Everything works fine but the Datepicker does not show up.
My Django version is 1.10.7 and the third party apps I am using are:
- Django Bootstrap 3 (
pip install django-bootstrap3
) - Django Bootstrap Datepicker Plus (
pip install django-bootstrap-datepicker-plus
)
This is my forms.py
, I override the DateInput
class to customize it according to my needs.
from django import forms
from bootstrap_datepicker.widgets import DatePicker
class DateInput(DatePicker):
def __init__(self):
DatePicker.__init__(self,format="%Y-%m-%d")
class UserUpdateForm(forms.ModelForm):
class Meta:
widgets = {
'date_of_birth': DateInput(), # datepicker
'creation_date': DateInput(), # datepicker
}
fields = ("other fields", "date_of_birth", "creation_date", "other fields",)
model = get_user_model()
Then in my template form, I have some base master template named layout.html
, My template user_form.html
in which I want render the form fields previously mentioned above. All this template have some of divs and html structure as you can see in user_form.html
file here.
In bootstrap settings in my settings.py I have to include_jquery
option to True
When I go to the form page, the date_of_birth field is not render as a calendar datepicker, this is render as a input type text in which the user should enter the date manually and in a specific format.
In my layout.html I am calling some additionals cdn jQuery resources to another things.
- Is this causing any conflict?
- Why datepicker widget in the form field is not rendering?
[Comments below are way older than this edit]
creation_date
anddate_of_birth
fields. ? Just in case, I am using a DJango widget for that .. – SymploceDateInput
which I assign in myUserUpdateForm
to the creation_date anddate_of_birth
. I've remove them and the dates in these fields are saved when I entered manually with their respective format. The topic now is implement some calendar date picker such as jqueryui.com/datepicker/#default – Symploce