Opened 14 years ago
Closed 12 years ago
#15244 closed New feature (wontfix)
Documentation needed for RadioFieldRenderer
Reported by: | Chris Beaven | Owned by: | lkeijser |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | renderer widget |
Cc: | mmitar@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Overriding the RadioSelect renderer is possible, but not documented.
Attachments (1)
Change History (10)
comment:1 by , 14 years ago
Component: | Uncategorized → Documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 14 years ago
Attachment: | doc-custom_renderer_howto.patch added |
---|
comment:2 by , 14 years ago
Keywords: | renderer widget added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Triage Stage: | Accepted → Ready for checkin |
Version: | → SVN |
I've created a patch against the latest trunk (rev. 15487). As this is my first patch, format might not be correct so please review.
comment:3 by , 14 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Ready for checkin → Accepted |
First off, thank you for the patch.
Second, in the future please don't mark your own patch as "Ready For Checkin"--when you upload a patch you should mark the "has patch" checkbox, and then once it has been peer-reviewed the reviewer will either provide feedback on the ticket or decide it looks good and mark it as RFC.
Before I get to the patch itself, I'd like to point out that the existence of RadioFieldRenderer
is inconsistent in and of itself. All the other widgets contain the rendering logic inside their own render
methods, and you would customize them at that point. Even the other "special case" input type--select
--doesn't get a special "renderer" class. I see why the renderer class is useful, it's just inconsistent.
As for the patch itself:
- I would rather see this information added to the widgets reference documentation instead of creating a new how to page. I've always been surprised that there wasn't a topic guide on widgets, but that's the subject of a different ticket. Right now, when people want to know about widgets, they go to
ref/forms/widgets
and there's already information about "customizing widgets" there... so let's keep the information together.
- Because
RadioFieldRenderer
is a completely one-off solution, more care should be taken to note that this does not apply to all widgets, just this one.
- The
force_unicode(w) for w in self
on line 21 ought to be explained. I know what it does because I've read the code forRadioFieldRenderer
and know that it has a custom__iter__
method which yieldsRadioInput
objects, but that's not readily obvious to anyone else.
- The new documentation about customizing the radio widget should be linked from the RadioSelect widget docs.
- Your first example imports
mark_safe
andStrAndUnicode
which are not used.
- On a purely grammatical note, "In particular its renderer function." [lines 9-10 of your patch] is a sentence fragment.
- Not that there's anything technically wrong with is, but I might pick a field name other than
os
for the example simply becauseos
is a very common python module and there's no reason to trigger confusion in people's minds.
This patch is a good start, and with a little more work will make a valuable addition to the docs. With a quick turnaround it can even still make it into the 1.3 milestone.
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:7 by , 13 years ago
Cc: | added |
---|
comment:8 by , 12 years ago
I started revising this patch per Russ's feedback, but I noticed Django 1.4 allows looping over the radio choices in the template. This seems like a much easier solution to the problem this patch attempts to solve. Should we still include this?
comment:9 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
And upon further reading (#15667), I see this API is being deprecated, closing this as won't fix in light of that.
patch to include custom renderer documentation