Opened 17 years ago
Closed 16 years ago
#4321 closed (wontfix)
BoundField.as_hidden() assumes hidden_widget is a class
Reported by: | Chris Beaven | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | newforms | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The hidden_widget
of a field could just as easily be (and is, in a case I'm using) a Widget instance rather than a Widget class but BoundField.as_hidden()
assumes that it is always a class.
Simple patch attached checks first before trying to instantiate the hidden_widget
.
Attachments (1)
Change History (4)
by , 17 years ago
Attachment: | hidden_widget.patch added |
---|
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
isinstance bad, duck typing good: this patch would break if hidden_widget
:
- was a class but not a subclass of Widget
- was some other callable that returned a widget e.g. a function that wraps a Widget constructor
In fact, thinking of the latter, you can work around this perfectly if you set hidden_widget = lambda: my_widget_instance
, AFAICS
So, seeing it is currently flexible enough to cope, and adding this would make it much less flexible, I'm closing WONTFIX, please reopen if I missed something.
What's the use case for
hidden_widget
being an instance rather than a class?