Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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],
                }
            ),
        }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #datepicker #mindate #maxdate
ADD COMMENT
Topic
Name
4+4 =