📜  django modelform datetime - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:07.823000             🧑  作者: Mango

代码示例1
class BookingForm(ModelForm):
    check_in = DateTimeField(required=True, input_formats=["%Y-%m-%dT%H:%M", ])
    check_out = DateTimeField(
        required=True, input_formats=["%Y-%m-%dT%H:%M", ])
#NOTE: input_formats must be a list, even for a single format!
    class Meta:
        model = Booking
        fields = ['room', 'check_in', 'check_out']