Dr Mouse Dr Mouse - 4 months ago 23
Python Question

Daterangepicker for Django

I'm coming back with a very simple questions, yet I am not able to solve it on my own...

I found a powerful Daterangepicker in Javascript : http://www.daterangepicker.com/#ex5 . As I have never learned js, I would like to know how to pass the start and end dates out of the widget to the views.py file... The few hints I got came from this topic : Django and date range picker component for Twitter Bootstrap which only provides the code for Django and not the js.

Many thanks !

Answer

You can find the function in http://www.daterangepicker.com/#ex5

function(start, end, label) {}

Use AJAX requests to send this data to server(view).Something like

function(start, end, label) {
    $.post("url",
    {
       "start":start,
       "end": end
    },
    function(data, status){
        alert("Data sent);
    });

}