我试图让datepicker在Django以我的形式工作,但由于某些原因它不起作用。我的基本模板中有jquery。在
#forms.py
class ScheduleForm(forms.ModelForm):
start_date = forms.DateField(widget=forms.DateInput(attrs={'class':'datepicker'}), initial=datetime.date.today, label="Start Date")
# insert other fields here
class Meta:
model = Schedules
fields = ('course_name', 'location', 'room', 'start_date', 'start_time', 'end_time', 'instructor', 'total_hours', 'hours_per_class', 'frequency', 'status', 'interval',)
#start_one_schedule.html
{% block main_content %}
<script>
$(function() {
$('.datepicker').datepicker({
format: 'yyyy-mm-dd'
});
});
</script>
<h2>Initial Course Schedule</h2>
<br>
<form id="schedule_form" method="post" action="/schedule/start_one_schedule/">
{% csrf_token %}
{{ form.errors }}
{% for field in form %}
<table class="init_sched_form">
<tr class="init_sched_row">
<td class="init_sched_label">{{ field.label_tag }}</td>
<td class="init_sched_field">{{ field }}</td>
</tr>
</table>
{% endfor %}
<button type="submit" name="submit">Initial Schedule</button>
<button type="submit" name="submit">Preview Schedule</button>
</form>
{% endblock %}
我不知道我做错了什么,因为我已经用其他答案检查过了。我需要在另一个模块中做些什么吗?在
编辑:这是我的基本.html公司名称:
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐