I have this Datetime field in Django
update_date = models.DateField()
But I want the Calendar to pop up. In docs, they say to write this
class CalendarWidget(forms.TextInput):
class Media:
css = {
'all': ('pretty.css',)
}
js = ('animations.js', 'actions.js')
Now I have a few problems:
- Where to declare this class and how to use it
- I don’t have pretty.css , animation.css , how can get it
- Do I need to do programming for it??
The files ‘pretty.css’, ‘animations.js’ and ‘actions.js’ are not included with Django, this code in the docs is an example only. It is your duty to write the code for fancier widgets – personally I like jQuery widgets (see the reference links bellow). From the docs:
Supposing you got all the css and js defined for your fancy widget, in the ModelForm you have to override the field widget like this:
Don’t forget to display the form media at the template header.
Look these answers: