Reputation: 8978
Using the django admin application for a date it displays Today | CalendarSymbol
. I am using a datefield in my form and I thought it would do this for me how would i go about doing this? As i would normally use the jquery datepicker plugin is this the way to go?
Thanks in Advance,
Dean
Upvotes: 0
Views: 413
Reputation: 8978
I used the admin like widget in the end was easy to implement plus no external libraries.
Upvotes: 0
Reputation: 2958
Usually I do something like this:
class CalendarWidget(forms.TextInput):
class Media:
css = {
'all': ('datepicker.css',)
}
js = ('datepicker.js')
def __init__(self, attrs={}):
super(CalendarWidget, self).__init__(
attrs={'class': 'datepicker',
'size': '14',
'readonly':'readonly'})
class ToDoForm(forms.ModelForm):
class Meta:
model = yourModel
your_date_field = forms.DateTimeField(widget=CalendarWidget)
Finally in your template, something like this:
$(".datepicker").datepicker();
I hope it helps.
Upvotes: 1