如何在Type = datetime-local的UpdateView中使用ModelForm?

问题描述

class AppointmentViewForm(ModelForm):

    class Meta:
        model = Appointment
        fields = '__all__'
        widgets = {
            'appointment_date': DateTimeInput(
                format =('%Y-%m-%d %H:%M'),attrs={
                    'type': 'datetime-local'
                },)
        }

我想在打算用作form_class的ModelForm中为DateTimeField使用DateTimeInput而不是TextInput。当我将ModelForm渲染到UpdateView中时,所有其他对象字段通常都会被实例化。但是,如果我将小部件用于“ appointment_date”,则会返回具有空白字段表单的字段(无datetimefield实例)。

在未被实例化的字段上,我无法使用表单中的当前信息保存表单。有什么办法可以解决这两个问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)