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

210
Vistas
How to put object datefield in html input value

I have a class "client" with an attribute datefield called "birth_date". I want to give the possibility for update this field. How can i put the default value in the form, in the input type date? Because the format in "client.birth_date" is different.

{{client.birth_date}} <br>
        </div class="form-group">
            <label for="birth_date">Data di Nascita:</label>
            <input type="date" class="form-control" id="birth_date" name="birth_date" value="{{client.birth_date}}" >
        </div>

enter image description here

If i try with, for example:

 </div class="form-group">
            <label for="birth_date">Data di Nascita:</label>
            <input type="date" class="form-control" id="birth_date" name="birth_date" value="2018-02-01" >
        </div>

The input value is setting true, but the format is different from the one i get

almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try to format the date like so:

<input type="date" name="birth_date" id="birth_date" value="{{ client.birth_date|date:'Y-m-d' }}">

Or set the default date format in settings.py:

DATE_FORMAT = "Y-m-d"
almost 4 years ago · Santiago Trujillo Denunciar
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