Skip to content
Advertisement

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.

JavaScript

enter image description here

If i try with, for example:

JavaScript

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

Advertisement

Answer

Try to format the date like so:

JavaScript

Or set the default date format in settings.py:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement