Datetimepicker format is not working 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();
});

Can anyone suggest a solution to solve this issue?

Back to Top