I have created a form in an application that goes like this :
<form action="" style="max-width:500px;margin:auto">
<div class="input-container_sensor_form">
<div class="row">
<div class="col-6">
<input class="input_field_sensor_form" type="text" placeholder="Sensor name" name="sensor_name">
</div>
<div class="col-6">
<span class="text-center">
<select name="sensor_form_sensor_category" class="sensor_form_sensor_category" id="sensor_form_sensor_category" class="select2-hidden-accessible" aria-hidden="true" data-select2-id="sensor_form_sensor_category">
<option></option>
<option name="tree_sensor" >Tree Sensor</option>
<option name="weather_sensor" >Weather Station</option>
</select>
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<input class="input_field_sensor_form" type="text" id="latitude" placeholder="Latitude" name="latitude">
</div>
<div class="col-6">
<input class="input_field_sensor_form" type="text" id="longitude" placeholder="Longitude" name="longitude">
</div>
</div>
</div>
<br>
<div id="map_sensor_form"></div>
<br>
<input type="hidden" id="field_id" name="field_id" value="">
<button type="submit" class="btn_sensor_form">Register</button>
</form>
with the following form :
class AddSensor(forms.Form):
sensor_name = forms.CharField(max_length=200 )
choice = forms.ChoiceField()
longitude = forms.DecimalField(max_digits=22, decimal_places=16)
latitude = forms.DecimalField(max_digits=22, decimal_places=16)
How do i match the inputs with the form ? I've seen in the django doc that its referencing it through label but I do not have any. I want to keep the form as it is .
forms.ModelFormas there are some differences to my model and those are the only values i want to saverequest.GET.get('any_name')and save it in the model. One more thing remove the empty action attribute, then also it will take current page route..is_valid()easier? Django docs useforms.CharField(label='Your name', max_length=100)is there something similar for my case?is_valid(), if you render django's form but in your case, you cannot use that, but you can use html functionality in forms for restrictions. Do you want me to write an answer, that how can you save data to model using html's form?