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

208
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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