Issue
I'm trying to display a date in an input field as so:
<tr><td>Date of Birth</td><td><input type="date" name="DOB" value="{{m.dob|date:"d/m/Y"}}" required=True></td></tr>
where m.dob is defined in the model as:
dob = models.DateField('Date of Birth', blank=True, null=True)
The HTML input tag shows the date as dd/mm/yyyy when the page is loaded but I can see the field has taken the value assigned. How do I get it to display correctly?
Thanks for help
Solution
The problem is value="{{m.dob|date:'d/m/Y'}}"
which must be specified as value="{{m.dob|date:'Y-m-d'}}"
Answered By - HenryM
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.