I have a form with a hidden input with a default value of 0 as set by the model.
The value of the input is updated correctly via JQuery, however, on submit the value recorded in the table is always 0, the default value.
date = forms.CharField(widget=DatePickerInputRange())
nights = forms.IntegerField(initial=0)
class Meta: model = Booking fields = ['date', 'nights] def __init__(self, *args, **kwargs): super(BookingForm, self).__init__(*args, **kwargs) self.fields['nights'].disabled = True
**The inspected html pre-submit:** <input type="number" name="nights" value="4" class="form-control" placeholder="Nights" title="" required="" disabled="" id="id_nights">
And yet the submit value is always the models’s default of 0.
Please, how can I get this to work?
If I remove the “self.fields[‘nights’].disabled = True” from forms.py, it works perfectly.