I want to add a datetime picker input field in my django project.
I found this tutorial that offers a few ways but all of them are using forms.py
as following:
from django import forms
class DateForm(forms.Form):
date = forms.DateTimeField(
input_formats=['%d/%m/%Y %H:%M'],
widget=forms.DateTimeInput(attrs={
'class': 'form-control datetimepicker-input',
'data-target': '#datetimepicker1'
})
)
But I am not using forms in my project. I am using the function views. I can't find an example of how to implement a DateTime picker in this way?!
any help is appreciated.
Alright so heres an example django form you can create and use in your view:
then in your views.py
then just render the form as you would regularly in your_form_view.html: