Opened 14 years ago

Closed 14 years ago

#14407 closed (fixed)

ManyToManyRawIdWidget.value_from_datadict is inexplicably complicated and can be simplified

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

Description

ManyToManyRawIdWidget.value_from_datadict can be simplified from:

!#python
    def value_from_datadict(self, data, files, name):
        value = data.get(name, None)
        if value and ',' in value:
            return data[name].split(',')
        if value:
            return [value]
        return None

to:

    def value_from_datadict(self, data, files, name):
        value = data.get(name)
        if value:
            return value.split(',')

Attachments (1)

patch.diff (616 bytes ) - added by Germano Gabbianelli 14 years ago.
I've not tested it

Download all attachments as: .zip

Change History (2)

by Germano Gabbianelli, 14 years ago

Attachment: patch.diff added

I've not tested it

comment:1 by Honza Král, 14 years ago

Resolution: fixed
Status: newclosed

(In [14283]) Fixed #14407 -- Simplified ManyToManyRawIdWidget.value_from_datadict, Thanks tyrion!

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