Skip to content
Advertisement

Add a date picker to an already existing html form with Django

I have this template that i use for my Django app :

JavaScript

I want to add a date picker (actually two of them) in the specified location in the code, the dates would then be sent as a variable when user click on submit form. I tried following the walkthrough tutorial for django-bootstrap-datepicker-plus but it just doesn’t fit right for me, i’m not using any generic view. If more details are needed please let me know.

Advertisement

Answer

If you’re looking this up, here’s how i did it (simplest way i could), I used XDSoft DateTimePicker, it is a jQuery plugin.

first include the required css and js files of the plugin to your html by adding the following code inside head tag

JavaScript

then add the datepicker js code where you want to have your datepicker in your html body

JavaScript

and it’s gonna look like this : enter image description here

Note : it is interpreted as string, so i personally had to convert it to datetime as i’m working with python.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement