Opened 6 years ago
Closed 6 years ago
#30831 closed Bug (invalid)
Django doesn't respect overriding the maxlength widget attribute for CharFields in ModelForm.
| Reported by: | Arsenal591 | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | 2.2 |
| Severity: | Normal | Keywords: | form, modelform |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I have the following field in model:
short_description = models.CharField(max_length=205)
and the widget in ModelForm:
'short_description': forms.Textarea(attrs={'rows': '3', 'minlength': 250,'maxlength': 250})
The issue:
In HTML, input, Django adds correctly minlength value, but for the maxlength value he get the value from the model field and not the one specified in the widget.
<textarea name="short_description" cols="40" rows="3" minlength="250" maxlength="205" required="" id="id_short_description"></textarea>
Change History (1)
comment:1 by , 6 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
| Summary: | Django doesn't respect the maxlength widget attribute → Django doesn't respect overriding the maxlength widget attribute for CharFields in ModelForm. |
Note:
See TracTickets
for help on using tickets.
Thanks for this report, however this is a documented and expected behavior (see Field types and Overriding the default fields):