我试图使用DateInput,但是我收到以下错误
// Call this function to save and unfinished edit
// - If an input exists with the "edit-call" class then the edit has
// not been finished. Complete the edit by injecting an "Enter" key press
function saveEdits() {
var $input = $("#grid").find(".edit-cell input");
if ($input.length == 1) {
var e = $.Event("keydown");
e.which = 13;
e.keyCode = 13;
$input.trigger(e);
}
}
Required argument 'year' (pos 1) not found
(第52行)
forms.py
{{ form.incident_date_time_reported|add_class:"form-control"}}
的index.html
from django import forms
import datetime
from functools import partial
DateInput = partial(forms.DateInput, {'class': 'datepicker'})
class IncidentForm(forms.Form):
incident_date_time_reported = forms.DateField(initial=datetime.date, required=False, widget=forms.DateInput)
def search(self):
# cleaning the data
incident_date_time_reported = self.cleaned_data.get('incident_date_time_reported')
query = Incident.objects.all()
if incident_date_time_reported is not None:
query = query.filter(incident_date_time_reported=incident_date_time_reported)
return(query)
答案 0 :(得分:4)
datetime.date使用不当。它是一个包含所有必需参数的函数。
如果您尝试最初填充当天,则应使用datetime.date.today
。
答案 1 :(得分:-1)
我已解决此问题,删除项目中的迁移文件夹