Opened 5 years ago

Closed 5 years ago

#14407 closed (fixed)

ManyToManyRawIdWidget.value_from_datadict is inexplicably complicated and can be simplified

Reported by: tyrion Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation:
Needs tests: Patch needs improvement:
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 tyrion 5 years ago.
I've not tested it

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by tyrion

I've not tested it

comment:1 Changed 5 years ago by Honza_Kral

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

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

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