Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#14363 closed (fixed)

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

Reported by: Germano Gabbianelli Owned by: Jannis Leidel
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: no UI/UX: no

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 Germano Gabbianelli 14 years ago.
fix-None-attrs-with-tests.diff (2.4 KB ) - added by David Novakovic 14 years ago.

Download all attachments as: .zip

Change History (6)

by Germano Gabbianelli, 14 years ago

Attachment: patch.diff added

comment:1 by Jannis Leidel, 14 years ago

Status: newassigned
Triage Stage: UnreviewedAccepted

by David Novakovic, 14 years ago

comment:2 by David Novakovic, 14 years ago

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 by Jannis Leidel, 14 years ago

Resolution: fixed
Status: assignedclosed

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

comment:4 by Jannis Leidel, 14 years ago

(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