Opened 2 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#35889 closed Cleanup/optimization (fixed)

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: Ready for checkin
Has patch: yes 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 (10)

comment:1 by Antoliny, 2 weeks ago

Owner: set to Antoliny
Status: newassigned

comment:2 by Antoliny, 2 weeks 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 weeks ago

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

Version 0, edited 2 weeks ago by Antoliny (next)

comment:4 by Sarah Boyce, 2 weeks 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):

comment:5 by Antoliny, 2 weeks ago

Thank you for your good suggestion !! Sarah Boyce :0

comment:6 by Antoliny, 2 weeks ago

Has patch: set

comment:7 by Antoliny, 2 weeks ago

comment:8 by Sarah Boyce, 2 weeks ago

Triage Stage: AcceptedReady for checkin

comment:9 by Sarah Boyce <42296566+sarahboyce@…>, 2 weeks ago

Resolution: fixed
Status: assignedclosed

In 18b3a9dd:

Fixed #35889 -- Corrected reference of default widgets in "Styling widget instance" docs.

comment:10 by Sarah Boyce <42296566+sarahboyce@…>, 2 weeks ago

In fe12428c:

[5.1.x] Fixed #35889 -- Corrected reference of default widgets in "Styling widget instance" docs.

Backport of 18b3a9dd395278232354a4f2507660a4f849c6eb from main.

Note: See TracTickets for help on using tickets.
Back to Top