I am trying to display a datepicker on my web little project with the help of django frame.
The case is that when I do the request to my page it displays everithing ok, but the datepicker calendar do not pop-up.
Could you help me? My code is:
My class:———————————————————————————–
class clientcheckform(ModelForm):
class Meta:
model = client
fields = ('checkin',)
widgets = {
'checkin': forms.DateTimeInput(format='%d%m%Y',attrs={
'class':'input',
'readonly':'readonly',
'size':'15',
})
}
My view.py ——————————————————————————–
def index(request):
client_check = clientcheckform()
template = loader.get_template('booking/index.html')
context = Context({
'client_check': client_check,
})
return HttpResponse(template.render(context))
To display I am using this template:—————————————————
<p><b></br>Select CheckIn Day: </b></p>
<head>
<link type="text/css" href="/media/css/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="/media/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/media/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript">
jQuery(function() {
jQuery('#checkin').datepicker({ dateFormat: 'dd/mm/yy' });
});
</script>
</head>
{{client_check}}
I would greatly appreciate your help.
Thanks. Victor.
“jQuery is not defined” means jQuery.js is not loaded.
From looking at your code, it is probably one of the following two reasons:
<head>tag around<script>and<link>./media/js/jquery-1.6.2.min.jswithhttp://code.jquery.com/jquery-1.6.4.min.jsand see if this fixes the problem. If it does, there is something wrong with your jQuery file.