asaglimbeni / django-datetime-widget

Bootstrap django-datetime-widget is a simple and clean widget for DateField, Timefiled and DateTimeField in Django framework. It is based on Bootstrap datetime picker, supports both Bootstrap 3 and Bootstrap 2
Other
219 stars 125 forks source link

using Now as startDate #102

Open balinabbb opened 7 years ago

balinabbb commented 7 years ago

Hi,

I would like to use create a picker which won't accept past dates. This would be the correct syntax to make it possible. However beacuse of this and this line I can't use that sytax. If I use datetime.now() in django, that now will be the now of the backend application launch, and not the client side page load.

I commented this line, which solved my problem, but do you have some better idea? I have some solutions in mind if you are interested.

treyd commented 6 years ago

I'm having this same problem. I have the following options in my form:

    datetime_widget_opts = {
        'startDate': str(timezone.now())
    }
...
datefield = forms.DateTimeField(label="Start Date",
                                             widget=DateTimeWidget(
                                                 usel10n=True,
                                                 bootstrap_version=3,
                                                 options=datetime_widget_opts
                                             )
)
...

But, the widget still lets me pick dates in the past. Looking through the JS it seems startDate is the right parameter but I wonder if timezone.now() isn't in the right format, but the docs don't say how it should be. What format should startDate and endDate be in the config?