Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#14363 closed (fixed)

ManyToManyRawIdWidget.render is assuming `attrs` is always passed as a dict.

Reported by: tyrion Owned by: jezdez
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

    def render(self, name, value, attrs=None):
        attrs['class'] = 'vManyToManyRawIdAdminField'
        if value:
            value = ','.join([force_unicode(v) for v in value])
        else:
            value = ''
        return super(ManyToManyRawIdWidget, self).render(name, value, attrs)

Either if I pass something else than a dict-like object or if I don't pass nothing at all, the method will raise an exception.

Attachments (2)

patch.diff (788 bytes) - added by tyrion 5 years ago.
fix-None-attrs-with-tests.diff (2.4 KB) - added by dpn 5 years ago.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by tyrion

comment:1 Changed 5 years ago by jezdez

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Changed 5 years ago by dpn

comment:2 Changed 5 years ago by dpn

I've added some tests to the original patch.

I've also adjusted a couple of indentation issues that seemed to be in the same area of tests :)

comment:3 Changed 5 years ago by jezdez

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [13971]) Fixed #14363 -- Fixed render method of ManyToManyRawIdWidget to set attrs to an empty dict. Thanks, tyrion and dpn.

comment:4 Changed 5 years ago by jezdez

(In [13975]) [1.2.X] Fixed #14363 -- Fixed render method of ManyToManyRawIdWidget to set attrs to an empty dict. Thanks, tyrion and dpn.

Backport from trunk (r13971).

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