Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
django jQuery date picker wont change date format

I have a django form which as two date fields. I am trying to have a Calendar Pop-up with the default date being sent on click as ("yyyy-mm-dd"). I have tried this several ways, changed the setting in the javascript, changed the django settings file, but no matter what the form says invalid date and the date format that gets sent to the field always is mm/dd/yyyy.

Here is an example of the code In the form I have:

from django import forms
from  functools import partial
DateInput = partial(forms.DateInput, {'class': 'datepicker'})

class SearchForm(forms.Form):

    start_date = forms.DateField(widget=DateInput(format = '%Y-%m-%d'),
        required=False,
        input_formats=['%Y-%m-%d'])
    end_date = forms.DateField(widget=DateInput(format = '%Y-%m-%d'),
        required=False,
        input_formats=['%Y-%m-%d'])

My tempplate has the following:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script>
$(document).ready(function() {
    $('.datepicker').datepicker()
});
</script>
<TR>
<TD COLSPAN="3" ALIGN="Center"> Start Date:&nbsp;{{ form.start_date }}&nbsp;&nbsp;
      End Date:&nbsp;{{ form.end_date }}
      Date Format <B>MUST</B> be YYYY-MM-DD<br>
      Dates are inclusive.<br>
If a date is left blank it is assumed to go until the start or end.</TD>
    </TR>

I have tried putting dateFormat('yyyy-mm-dd') inside the datepicker code , as well as format('yyyy-mm-dd'), format('yy-mm-dd'). None of them changes the way to date is sent to the field, it's always "mm/dd/yyyy'. The form says this is not a valid date.

I know there are posts about this, but none of the ones I have tried have changed the outcome.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda