Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python datepicker不在django工作?_Python_Jquery_Django_Jquery Ui Datepicker - Fatal编程技术网

Python datepicker不在django工作?

Python datepicker不在django工作?,python,jquery,django,jquery-ui-datepicker,Python,Jquery,Django,Jquery Ui Datepicker,在base.html中添加的脚本 我的班级以forms.py的形式上课 My model.py中的模型 我的Django HTML,我的出发日期 <label class="control-label col-sm-2"> Departure Date</label> <div class="col-sm-10">{{form.departure_date}} 我正在尝试在MesslaveModel的“出发日期”字段中添加datepicker。我已经在bas

在base.html中添加的脚本

我的班级以forms.py的形式上课

My model.py中的模型

我的Django HTML,我的出发日期

<label class="control-label col-sm-2"> Departure Date</label>
<div class="col-sm-10">{{form.departure_date}}

我正在尝试在MesslaveModel的“出发日期”字段中添加datepicker。我已经在base.html中添加了相关脚本,并通过MessLeaveForm的meta类中的小部件添加了这个类。我已经在messLeaveForm.html中扩展了base.html,并在那里进行了输入。datepicker完全没有响应。

您可能需要查看django tempus dominus包,其中包含用于django的Bootstrap 4 datepicker小部件:


这是jQuery Tempus Dominus库的一组垫片,它是引导数据选择器的完整重写继承者。祝你好运

当我实现您的方法时,日历并没有显示在DateField中,而时间字段显示的是不需要的。您可以在上面的google drive链接中看到屏幕截图。谢谢。您是否包括用于出发日期和出发时间的代码?谢谢
class MessLeaveForm(forms.ModelForm):

    departure_date = forms.DateField()
    arrival_date = forms.DateField(widget=forms.DateInput(format='%d/%m/%Y'))
    departure_time = forms.TimeField(widget=forms.TimeInput(format='%H:%M'))
    arrival_time = forms.TimeField(widget=forms.TimeInput(format='%H:%M'))
    verification = forms.ChoiceField(choices=BOOL_VALUES,initial="Pending",widget=forms.HiddenInput(),required=False)
    approval = forms.ChoiceField(choices=BOOL_VALUES,initial="Pending",widget=forms.HiddenInput(),required=False)
    status = forms.ChoiceField(choices=BOOL_VALUES,initial="Pending",widget=forms.HiddenInput(),required=False)
    hostel_suscribed = forms.ChoiceField(choices = HOSTEL_CHOICES,required = True)
    mess_manager_doc = forms.FileField(required=False)
    faculty_doc = forms.FileField(required=False)

    class Meta:
        model = MessLeaveModel
        fields = ('idNo','hostel_suscribed','departure_date','departure_time','arrival_date','arrival_time','mess_manager_doc','faculty_doc','verification','approval','status')
        widgets = {
            'departure_date': forms.DateInput(attrs={'class':'datepicker'}),
        }
class MessLeaveModel(models.Model):
    # user = models.ForeignKey(OccupantDetails,null=True,on_delete=models.CASCADE)
    idNo = models.ForeignKey(OccupantDetails,on_delete = models.CASCADE)
    username = models.CharField(max_length=255, null=False,blank=False,default="")
    hostel_suscribed = models.CharField(max_length=255,choices = HOSTEL_CHOICES,null=True)
    departure_date = models.DateField()
    arrival_date = models.DateField()
    departure_time = models.TimeField(null = True,blank = True)
    arrival_time = models.TimeField(null=True,blank=True)
    faculty_doc = models.FileField(upload_to='documents/',null=True,blank=True)
    mess_manager_doc = models.FileField(upload_to='documents/',null=True,blank=True)
    verification = models.CharField(max_length=255,choices=BOOL_VALUES,default="Pending")
    approval = models.CharField(max_length=255,choices=BOOL_VALUES,default="Pending")
    status = models.CharField(max_length=255,choices=BOOL_VALUES,default="Pending")
    comment = models.CharField(max_length=255,blank=True,null=True,default="")


    def __str__(self):
        return '%s_%s_%s' %(self.idNo,self.departure_date,self.arrival_date)
<label class="control-label col-sm-2"> Departure Date</label>
<div class="col-sm-10">{{form.departure_date}}