Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

235
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda