#11185 closed Cleanup/optimization (fixed)
Document how to customize widgets
Reported by: | Ben Smith | Owned by: | Tim Graham |
---|---|---|---|
Component: | Documentation | Version: | 1.0 |
Severity: | Normal | Keywords: | widget |
Cc: | fadeev, timograham@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It would be nice to have documentation on how to customize form widgets. Here's an example of something that I just figured out, and that would be nice to see in the documentation.
You can customize how a widget is rendered by overriding it's renderer.render method. This class renders radio buttons as a horizontal line, instead of in a list.
class HorizRadioRenderer(forms.RadioSelect.renderer): def render(self): """Outputs radios""" return mark_safe(u'\n'.join([u'%s\n' % w for w in self]))
Attachments (2)
Change History (17)
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 15 years ago
comment:3 by , 14 years ago
milestone: | → 1.3 |
---|
comment:4 by , 14 years ago
Cc: | added |
---|---|
Owner: | changed from | to
by , 14 years ago
Attachment: | widget-evgeny1.diff added |
---|
finished reference for creation of custom widgets, improved cross-linking between form-fields, widgets, and form media pages, changed link on main page from Built-in widgets to Widgets
comment:5 by , 14 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Reference part for the Custom Widget is done, still need to create a topic guide, which probably should be a separate ticket.
Also, organized the widget.txt doc a bit - split widget classes into several logical groups and added section on how to add media to the widgets.
comment:6 by , 14 years ago
Has patch: | set |
---|---|
Resolution: | worksforme |
Status: | closed → reopened |
@fadeev -- You only close a ticket when it has actually been committed to trunk. You're looking for the 'has patch' flag -- that tells other people that there is a patch that needs to be reviewed.
comment:7 by , 14 years ago
Easy pickings: | unset |
---|---|
Severity: | → Normal |
Type: | → Uncategorized |
This ticket may be superseded by #15667, specifically RadioSelect.rendered is being deprecated and the widget API is being overhauled/documented. Documenting the current behavior in 1.3 may be counterproductive by encouraging people to develop against an API that is going away.
comment:8 by , 14 years ago
Type: | Uncategorized → Cleanup/optimization |
---|
comment:9 by , 13 years ago
Patch needs improvement: | set |
---|---|
UI/UX: | unset |
The doc about widgets has recently been improved in [16408], however there are still several bits from the patch in this ticket that are worth considering. The patch now needs to be updated to fit with the latest version of the doc.
comment:11 by , 12 years ago
Cc: | added |
---|---|
Owner: | changed from | to
Status: | reopened → new |
I'm working on updating the patch from fadeev
comment:12 by , 12 years ago
Patch needs improvement: | unset |
---|
comment:13 by , 12 years ago
Globally looks good to me. Some minor typos: "is is combined", "which is probably is", "customise", "all memeber". You might also want to capitalize 'css file's to 'CSS files' for consistency.
comment:14 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I am also missing documentation on how to actually write your own custom widgets. Is this worth a separate ticket?