Reputation: 143
Imagine that in a Educational Management System I have created a form for entering the details for a ,let say, course. After I save it to the database(in my case postgres) I want to provide the user with the opportunity to edit the previously saved form. So I have to initialise a form with the initial values that user has previously entered. Everything is Alright but the problem is that I cannot format the the TIME input (let say the time that course starts) received from the database into a proper shape to be suitable for in my html. So the initial value is not shown in the time input.How can I solve this problem?
initial form:
<form action="/courses/new_course/" method="POST">
<div class="d-flex flex-column mb-3 p-2">
<label for="due_exam_time">Due Exam Time:</label>
<input type="time" name="due_exam_time" >
</div>
</form>
The same form with the previously-user-entered value for updating the value of the time input
<form action="/courses/update_course/{{ course.id }}" method="POST">
<div class="d-flex flex-column mb-3 p-2">
<label for="due_exam_time">Due Exam Time:</label>
<input type="time" name="due_exam_time" value={{course.start_time}} >
</div>
</form>
The format of the course.start_time is not suitable for time input of html so it remain empty like --:--
Upvotes: 0
Views: 192