I'm using Django with Date-Picker-Plus. Everything works correctly, except the date picker displays/has no value until you click the box.
I have dug through all the documentation and can't find any references elsewhere of someone having this problem. I'm not familiar with js much so this is a bit foreign to me.
Heres the documentation I've gone thru:
https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/Usage.html http://eonasdan.github.io/bootstrap-datetimepicker/Options/#defaultdate
class Meta:
model = Jobs_DB
fields = ['date_scheduled']
widgets = {
'date_scheduled': DatePickerInput(
options={
"format": "MM-DD-YYYY", # moment date-time format
"showClose": True,
"showClear": True,
"showTodayButton": True,
'defaultDate': True,
},
),
}
I do it in JavaScript. The Python package datetimepickler_plus does not document how to set a date/time option, and I was too lazy to debug this or look into the code. This is the JS code (jQuery required):
const now = new Date();
$('.input-group.date')
.find("input").data("DateTimePicker")
.defaultDate(now)
.maxDate(now);
This sets the initial date (defaultDate call) and the maximum date (maxDate call). You probably have to adjust the query selector to suit your needs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.