Opened 2 hours ago
Last modified 73 minutes ago
#35889 assigned Cleanup/optimization
Incorrect reference of defaults widgets in "Styling widget instances" docs
Reported by: | Antoliny | Owned by: | Antoliny |
---|---|---|---|
Component: | Documentation | Version: | 5.0 |
Severity: | Normal | Keywords: | Widget Document |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello!
I found an incorrect sentence in the Django widgets document customizing widget instances section.
For example, take the following form:: from django import forms class CommentForm(forms.Form): name = forms.CharField() url = forms.URLField() comment = forms.CharField() This form will include three default :class:`TextInput` widgets, with default rendering -- no CSS class, no extra attributes. This means that the input boxes provided for each widget will be rendered exactly the same:
The fields used in the above example CommentForm are CharField and URLField.
And the document has the following explanation.
"This form will include three default TextInput widgets"
CharField default widget is TextInput, but URLField default widget is URLInput.
That's why I think this sentence is wrong and should be corrected.
Change History (4)
comment:1 by , 2 hours ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 2 hours ago
comment:3 by , 2 hours ago
Both classes inherit Input class, So I think it would be okey to change TextInput to Input.
comment:4 by , 73 minutes ago
Summary: | Django widgets document customizing widget instances section incorrect sentence. → Incorrect reference of defaults widgets in "Styling widget instances" docs |
---|---|
Triage Stage: | Unreviewed → Accepted |
Thank you for spotting!
It looks like this was true when this was first written
I would suggest something like...
-
docs/ref/forms/widgets.txt
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index dd2ba0ac4c..950a852209 100644
a b For example, take the following form:: 142 142 url = forms.URLField() 143 143 comment = forms.CharField() 144 144 145 This form will include three default :class:`TextInput` widgets, with default146 rendering -- no CSS class, no extra attributes. This means that the input boxes 147 provided for each widget will be rendered exactly the same:145 This form will include :class:`TextInput` widgets for the name and comment 146 fields, and a :class:`URLInput` widget for the url field. Each with default 147 rendering - no CSS class, no extra attributes: 148 148 149 149 .. code-block:: pycon 150 150 … … provided for each widget will be rendered exactly the same: 154 154 <div>Url:<input type="url" name="url" required></div> 155 155 <div>Comment:<input type="text" name="comment" required></div> 156 156 157 On a real web page, you probably don't want every widget to look the same. You158 might want a larger input element for the comment, and you might want the 159 'name' widget to have some special CSS class. It is also possible to specify 160 the 'type' attribute to take advantage of the new HTML5 input types. To do 161 this, you use the:attr:`Widget.attrs` argument when creating the widget::157 On a real web page, you probably want to customize this. You might want a 158 larger input element for the comment, and you might want the 'name' widget to 159 have some special CSS class. It is also possible to specify the 'type' 160 attribute to use HTML5 input types. To do this, you use the 161 :attr:`Widget.attrs` argument when creating the widget:: 162 162 163 163 class CommentForm(forms.Form):
I'm thinking about how to revise this sentence. How about this sentence?
"This form will include TextInput, URLInput widgets, with default rendering - no CSS class, no extra attributes. This means that the input boxes provided for each widget will be rendered almost the same:"