Tempus Dominus Datetimepicker

(cix) #1

Hello Vitor,
Based on the link on your sit https://simpleisbetterthancomplex.com/tutorial/2019/01/03/how-to-use-date-picker-with-django.html
How is it possible to remove the AM/PM from the widget?
I have changed it to 24hours but still not able to escape the validation. It keeps returning the error Enter a valid date/time
Also, I have set the inputs_format = ['%Y-%m-%d %H:%M %p'] in the ModelForm and in between the script, format: HH:mm
Thank you in advance for your help

(Vitor Freitas) #2

Hi @divergent

This tempus dominus datetimepicker is good but I found the initialization process quite buggy.

When I was writing the tutorial I faced some weird behavior like you described.

It seems like the initialization of the datetimepicker wdiget is partially done via data attributes and partially done via JavaScript. And what happen is that sometimes the data attributes will break, and it will initialize anyway, but won’t load some configurations. So I would double check if something isn’t missing. At some point I had to copy their example and change stuff step by step to see where it was going wrong.

Another thing is that tempus dominus use the moment.js to format, so you can double check the formatting parameters here: https://momentjs.com/docs/#/displaying/format/

I will try to simulate it later on to see if I can find a solution for you

(cix) #3

Thank you for you response and time.
I will do more research on this issue as to what and where the break is happening and also, I await your solution.
Thank you once again for all you do.