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.
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization
--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:1>
* owner: nobody => killerbat00
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:2>
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>
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>
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>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/28095#comment:6>
* 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>
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>