Opened 6 years ago

Closed 6 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: UI/UX:

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 6 years ago.
I've not tested it

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by Germano Gabbianelli

Attachment: patch.diff added

I've not tested it

comment:1 Changed 6 years ago by Honza Král

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