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 Antoliny, 2 hours ago

Owner: set to Antoliny
Status: newassigned

comment:2 by Antoliny, 2 hours ago

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:"

comment:3 by Antoliny, 2 hours ago

Both classes inherit Input class, So I think it would be okey to change TextInput to Input.

Last edited 2 hours ago by Antoliny (previous) (diff)

comment:4 by Sarah Boyce, 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: UnreviewedAccepted

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::  
    142142        url = forms.URLField()
    143143        comment = forms.CharField()
    144144
    145 This form will include three default :class:`TextInput` widgets, with default
    146 rendering -- no CSS class, no extra attributes. This means that the input boxes
    147 provided for each widget will be rendered exactly the same:
     145This form will include :class:`TextInput` widgets for the name and comment
     146fields, and a :class:`URLInput` widget for the url field. Each with default
     147rendering - no CSS class, no extra attributes:
    148148
    149149.. code-block:: pycon
    150150
    provided for each widget will be rendered exactly the same:  
    154154    <div>Url:<input type="url" name="url" required></div>
    155155    <div>Comment:<input type="text" name="comment" required></div>
    156156
    157 On a real web page, you probably don't want every widget to look the same. You
    158 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::
     157On a real web page, you probably want to customize this. You might want a
     158larger input element for the comment, and you might want the 'name' widget to
     159have some special CSS class. It is also possible to specify the 'type'
     160attribute to use HTML5 input types. To do this, you use the
     161:attr:`Widget.attrs` argument when creating the widget::
    162162
    163163    class CommentForm(forms.Form):
Note: See TracTickets for help on using tickets.
Back to Top