Move the date with Jquery from a datatimeField generated with Django

0

I have a view that has a datetimepicker that I generate with Django such that:

class una(forms.Form):
start_edited_date = forms.DateTimeField(label="Fecha inicio", widget=DateTimeWidget(usel10n=True, bootstrap_version=3), required=False)
end_edited_date = forms.DateTimeField(label="Fecha fin", widget=DateTimeWidget(usel10n=True, bootstrap_version=3),required=False)



helper = FormHelper()
helper.form_class = 'form-horizontal'
helper.layout = Layout(
    'start_edited_date',
    'end_edited_date'                        
)

and a javascript function on the html page where the form is generated such that:

$(document).ready(function(){
          $('.glyphicon-pencil').on('click',function(){
              var dataURL = $(this).attr('data-href');
              var res = dataURL.split(",");
              $('#id_start_edited_date').val(res[0]);
              $('#id_end_edited_date').val({
                    date: new Date(res[1])
              });
              $('#edit_id').val(res[2]);

          });

Well, when I click on the button that opens the form, the datetimepicker does not have the time set and it appears empty.

Any ideas?

Thank you.

    
asked by XBoss 06.02.2018 в 19:23
source

0 answers