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
218 stars 125 forks source link

Back to 1899 #83

Open pisapapiros opened 8 years ago

pisapapiros commented 8 years ago

Hello,

I've been working with this widget for a while and I found it very useful for my project.

When it comes to fill a new datetime field everything is ok. However, attempting to open the widget for edition, it jumps back to 1899. It works, but I want to launch it from the date shown in the field.

image

My widget settings: dateTimeOptions = { 'format': 'dd.mm.yyyy hh:00', # I guess this is causing the problem 'autoclose': True, 'todayHighlight': True, 'minuteStep': 60, 'minView': 1, 'maxView': 2 }

I've tried to access to the widget from js, but I couldn't. Is it possible?

Thanks in advance

michaeljones commented 8 years ago

Hi, are you using localisation (the l10n option)? That can cause some issues as it overrides the date format.

pisapapiros commented 8 years ago

Hello michaeljones,

I'm not using it. This is my config: widgets = { 'date': DateTimeWidget(attrs={}, options=dateTimeOptions, bootstrap_version=3) }

Actually if I add "usel10n = True" the plugin doen't start from 1899, but my datetime format gets overwritten.

pisapapiros commented 8 years ago

Is there a way to reference the existing datepicker? like: $dateField.datepicker().

Or maybe implementing a callback after certain datepicker functions are executed? eg. after hiding it.

This would let me fix my issues :)

michaeljones commented 8 years ago

I'm not sure myself. I'd have to look into it further. Can I ask, does it behave better if you have dd.mm.yyyy hh:ii for the format? Or yyyy-mm-dd hh:ii? Which is what I have. That seems to work for me. I'm not saying you should use that but it would be interesting to know if it works.

pisapapiros commented 8 years ago

Sure you can ask! that format works perfect. The point is the user should only set the date and the hour, but always leave minutes and seconds to 0. That's way I use the format dd.mm.yyyy hh:00 instead of dd.mm.yyyy hh:ii, and use the options 'minView': 1,'maxView': 2.

Although if the form field is empty it does work, when it comes to editing an already saved datetime the widget must got broken or something and it opens the calendar in 1899. Initializing the widget with my custom format seems quite hard to handle for the module.

Am I missing a more effective way of fixing the minutes to 0?

shaunagm commented 7 years ago

@pisapapiros Did you ever find a fix for this? I'm also having this issue.

MSISM commented 6 years ago

Well, I have the same problem.