Bootstrap datepicker is not functioning properly?

I used datetimepicker to select month and year. On the first click of the page load ,datetimepicker shows months and year.But when I click on the same date field again to change the month, datetimepicker displays dates instead of months. Here I also used select2 in my code.I implemented it in Django web framework.

<script>
$(function(){
    $('#id_from_date').datetimepicker({
            format: 'MM/YYYY',
        });
    $('#id_to_date').datetimepicker({
            format: 'MM/YYYY',
        });
});
$(document).ready(function() {
    $('select').select2();
});
</script>

html code:

            <div class="col-lg-3 col-sm-12">
                <h4><b>From Month :</b></h4>
                {{form.from_date}}
            </div>
            <div class="col-lg-3 col-sm-12">
                <h4><b>To Month :</b></h4>
                {{form.to_date}}
            </div>

Can anyone suggest a solution to solve this issue?

Back to Top