Reputation: 9112
I am new to HTML, my problem is I can't make a form field to be linked to the form.field I try to link with. I had to write an HTML form manually and not simply use the {{form.field}} because I am using a datepicker with JQuery.
<div class="fieldWrapper">
{{ form.valida_desde.errors }}
<label for="id_valida_desde">Válida desde:</label>
<input type="text" data-date-format="mm/dd/yy" id="valida_desde">
</div>
I could easily render this required field by doing:
{{ form.valida_desde.errors }}
{{ form.valida_desde }}
But that would not work with datepicker. So, what do I do so that the first form saves the data to form.valida_desde field, which is a DateField BTW.
The Jquery needed at the bottom, it works OK
<script>
$(function() {
$( "#valida_desde" ).datepicker();
});
</script>
EDIT:
Actually is pretty funny for the fact that I just found the answer after looking for more than 3 hours.
<div class="fieldWrapper">
{{ form.valida_desde.errors }}
<label for="id_valida_desde">Válida desde:</label>
<input type="text" name="valida_desde" data-date-format="mm/dd/yy" id="valida_desde">
</div>
Adding the name attribute made it, I did that but tried something like form.valida_desde and even {{ form.valiad_desde }}
Upvotes: 0
Views: 1123
Reputation: 9112
Actually is pretty funny for the fact that I just found the answer after looking for more than 3 hours.
<div class="fieldWrapper">
{{ form.valida_desde.errors }}
<label for="id_valida_desde">Válida desde:</label>
<input type="text" name="valida_desde" data-date-format="mm/dd/yy" id="valida_desde">
</div>
Adding the name attribute made it, I did that but tried something like form.valida_desde and even {{ form.valiad_desde }}
Upvotes: 2