[Django] #28095: Widget "build_attrs" changed method signature

83 views
Skip to first unread message

Django

unread,
Apr 19, 2017, 3:09:05 AM4/19/17
to django-...@googlegroups.com
#28095: Widget "build_attrs" changed method signature
------------------------------------------+------------------------
Reporter: Melvyn Sopacua | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------+------------------------
While build_attrs is undocumented (not sure why, since many widgets
override render() and make use of build_attrs) and changed it's method
signature in 1.11 by removing kwargs.

This isn't mentioned in the release notes.

A compatibility method could look something like this:


{{{
def build_attrs(self, extra_attrs=None, **kwargs):
# Django 1.11 changed method signature by removing kwargs
if extra_attrs:
kwargs.update(extra_attrs)
return super().build_attrs(extra_attrs=kwargs)

}}}

An update of the release notes would be very welcome.

--
Ticket URL: <https://code.djangoproject.com/ticket/28095>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 19, 2017, 9:34:26 AM4/19/17
to django-...@googlegroups.com
#28095: Document Widget.build_attrs() signature change in Django 1.11
--------------------------------------+------------------------------------

Reporter: Melvyn Sopacua | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization


--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:1>

Django

unread,
Apr 30, 2017, 2:34:00 AM4/30/17
to django-...@googlegroups.com
#28095: Document Widget.build_attrs() signature change in Django 1.11
-------------------------------------+-------------------------------------
Reporter: Melvyn Sopacua | Owner:
Type: | killerbat00
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by killerbat00):

* owner: nobody => killerbat00
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:2>

Django

unread,
Apr 30, 2017, 5:16:26 PM4/30/17
to django-...@googlegroups.com
#28095: Document Widget.build_attrs() signature change in Django 1.11
-------------------------------------+-------------------------------------
Reporter: Melvyn Sopacua | Owner: brian
Type: | houston morrow
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by brian houston morrow):

Created [https://github.com/django/django/pull/8443 pull request]
documenting the removal of kwargs as well as Widget.build_attrs.

This is the first time Widget.build_attrs is documented. Does it make
sense to document this in other stable branches as well? If so, would
those be appropriate for this PR?

--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:3>

Django

unread,
May 1, 2017, 9:54:35 AM5/1/17
to django-...@googlegroups.com
#28095: Document Widget.build_attrs() signature change in Django 1.11
-------------------------------------+-------------------------------------
Reporter: Melvyn Sopacua | Owner: brian
Type: | houston morrow
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Melvyn Sopacua):

I don't think it should be documented.

The apparent reason for making this backwards-incompatible change was that
it was deemed internal (''because'' it was not documented).
However - it is widely used in the field, as `Widget.render()` used to be
abstract and widget implementors copied code from `InputWidget` and
friends, which used build_attrs.

But because it is widely used and incompatible, it should be noted in the
release notes.

Personally, I expect this method to be removed, as it's nothing more then
a wrapper for `dict.update()`, with no added value (the fact that you
could pass keyword arguments that would be added as attributes was it's
added value, as that is much easier to type and read).

--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:4>

Django

unread,
May 1, 2017, 5:22:01 PM5/1/17
to django-...@googlegroups.com
#28095: Document Widget.build_attrs() signature change in Django 1.11
-------------------------------------+-------------------------------------
Reporter: Melvyn Sopacua | Owner: brian
Type: | houston morrow
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by brian houston morrow):

Okay, that makes sense.
I've removed that part of the commit and left the remaining changes to the
1.11 release note in this [https://github.com/django/django/pull/8447
pull request].

--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:5>

Django

unread,
May 1, 2017, 9:51:37 PM5/1/17
to django-...@googlegroups.com
#28095: Document Widget.build_attrs() signature change in Django 1.11
-------------------------------------+-------------------------------------
Reporter: Melvyn Sopacua | Owner: brian
Type: | houston morrow
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.11

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:6>

Django

unread,
May 6, 2017, 2:46:40 PM5/6/17
to django-...@googlegroups.com
#28095: Document Widget.build_attrs() signature change in Django 1.11
-------------------------------------+-------------------------------------
Reporter: Melvyn Sopacua | Owner: brian
Type: | houston morrow
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"e86f4786a7f39b0ed833c0699addf0c27811d864" e86f478]:
{{{
#!CommitTicketReference repository=""
revision="e86f4786a7f39b0ed833c0699addf0c27811d864"
Fixed #28095 -- Doc'd Widget.build_attrs() signature change in Django
1.11.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:7>

Django

unread,
May 6, 2017, 2:46:57 PM5/6/17
to django-...@googlegroups.com
#28095: Document Widget.build_attrs() signature change in Django 1.11
-------------------------------------+-------------------------------------
Reporter: Melvyn Sopacua | Owner: brian
Type: | houston morrow
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.11

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"4bdc832a7598c1811c5a50fb39c912c02ce87a39" 4bdc832]:
{{{
#!CommitTicketReference repository=""
revision="4bdc832a7598c1811c5a50fb39c912c02ce87a39"
[1.11.x] Fixed #28095 -- Doc'd Widget.build_attrs() signature change in
Django 1.11.

Backport of e86f4786a7f39b0ed833c0699addf0c27811d864 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:8>

Reply all
Reply to author
Forward
0 new messages