Opened 6 years ago

Closed 5 years ago

#17650 closed Cleanup/optimization (wontfix)

BaseForm doesn't implement __contains__

Reported by: Jaime Irurzun Owned by: anonymous
Component: Forms Version: 1.4-alpha-1
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


BaseForm currently implements iter and getitem, wrapping access to self.fields. It would be nice if it also implemented contains, so you could check for a name being a field of a form object.

Attachments (1)

baseform_contains.diff (1.3 KB) - added by Jaime Irurzun 6 years ago.

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by Jaime Irurzun

Attachment: baseform_contains.diff added

comment:1 Changed 6 years ago by Alex Gaynor

Triage Stage: UnreviewedDesign decision needed

Ugh, I'm actually concerned about this, because it breaks existing code. Currently field_instance in form works, because if __contains__ isn't defined the in operator falls back to iterating over this, which iterates over the values of fields, rather than the keys in that dict. This behavior is different from all other mapping containers, so this requires a lot more though IMO.

comment:2 Changed 5 years ago by vijay_shanker

Owner: changed from nobody to vijay_shanker
Status: newassigned

comment:3 Changed 5 years ago by anonymous

Owner: changed from vijay_shanker to anonymous

comment:4 Changed 5 years ago by Aymeric Augustin

Type: UncategorizedCleanup/optimization

comment:5 Changed 5 years ago by Aymeric Augustin

Resolution: wontfix
Status: assignedclosed

No one addressed Alex' point on backwards compatibility.

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