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

Accessing the Javascript hooks #35

Open michaeljones opened 10 years ago

michaeljones commented 10 years ago

Hi,

Firstly, thank you very much for writing this app and supporting it. I have found it very useful so far.

I currently have a form that has a start datetime field and an end datetime field. Currently they are independent but I would like to change it so that when a datetime is selected on the start field that value becomes the default/starting point for the end datetime field so that people are guided to the same date & time by default as they will frequently be on the same date and only hours apart.

I think this will involve responding to the changeData event from the time picker. I am new to this but I think I would either try to add my additional javascript to the datetime-picker template or try to reference the appropriate input field by its id. The first might be possible by overriding the datetimewidget.BOOTSTRAP_INPUT_TEMPLATE string, though that feels quite hacky and would have global effects and the second approach is difficult as the input's id is a randomly generated string.

Do you have any advice here? Am I missing an easier option? If not, would you be interested in supporting this workflow? I would be happy to try to contribute changes that might make it easier?

Kind regards and many thanks for the project, Michael

asaglimbeni commented 10 years ago

Hi Michel, as you can see in the millestone here : https://github.com/asaglimbeni/django-datetime-widget/issues/18 is one of the thing to do :) so any help is wellcome. My idea in the begining was to work principaly in the python code , in this way it is usefull for the devloper to have only one place (using the widget) where it could be controlled all teh configuration of the javascript part. The approch is the javascript /html have to be the result of the python code. So as the other widgets the Datetime Range need to rewirite the render method and if I would it works with two field in the same time (for the form or modelform) we need to find some solution for that, I guess it is the most diffucult thing to implement. Let me know what do you thing. Thank you so much for your help. Best regards Alfredo

ollytheninja commented 10 years ago

I need this sort of functionality also, I'd be happy to look into it when I have time (though that may not be for a few weeks). I assume it's a case of adding an extra option to the widget and some additional javascript.