Answers for "django datepicker mindate and maxdate"

0

django datepicker mindate and maxdate

from django import forms
from .models import Booking

import datetime


class BookingForm(forms.ModelForm):
    class Meta:
        model = Booking
        fields = ('booking_name', 'rental_price',
                'book_car', 'customer_name', 'times_pick',)
        widgets = {
            'times_pick': DateTimePickerInput(
                options={
                    'minDate': (datetime.datetime.today() + datetime.timedelta(days=1)).strftime('%Y-%m-%d 00:00:00'),
                    'maxDate': (datetime.datetime.today() + datetime.timedelta(days=2)).strftime('%Y-%m-%d 23:59:59'),
                    'enabledHours': [8, 9, 10, 11, 12, 13, 14, 15, 16, 17],
                }
            ),
        }
Posted by: Guest on March-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language