Opened 15 years ago

Closed 12 years ago

Last modified 12 years ago

#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)

widget-evgeny1.diff (18.8 KB ) - added by fadeev 14 years ago.
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
11185.diff (16.0 KB ) - added by Tim Graham 12 years ago.
Updated parts of fadeev that are still applicable

Download all attachments as: .zip

Change History (17)

comment:1 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by bjunix, 15 years ago

I am also missing documentation on how to actually write your own custom widgets. Is this worth a separate ticket?

comment:3 by Paul Oswald, 14 years ago

milestone: 1.3

comment:4 by fadeev, 14 years ago

Cc: fadeev added
Owner: changed from nobody to fadeev

by fadeev, 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 fadeev, 14 years ago

Resolution: worksforme
Status: newclosed

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 Russell Keith-Magee, 14 years ago

Has patch: set
Resolution: worksforme
Status: closedreopened

@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 dmclain, 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 Julien Phalip, 14 years ago

Type: UncategorizedCleanup/optimization

comment:9 by Julien Phalip, 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:10 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

comment:11 by Tim Graham, 12 years ago

Cc: timograham@… added
Owner: changed from fadeev to Tim Graham
Status: reopenednew

I'm working on updating the patch from fadeev

by Tim Graham, 12 years ago

Attachment: 11185.diff added

Updated parts of fadeev that are still applicable

comment:12 by Tim Graham, 12 years ago

Patch needs improvement: unset

comment:13 by Claude Paroz, 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 Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In a73838fde33374573b8e765dfcb0225287d396c0:

Fixed #11185 - Expanded docs on customizing widgets; thanks fadeev for the draft patch.

comment:15 by Tim Graham <timograham@…>, 12 years ago

In 1b5b8b874fb79a8d2b2bc7ca8f93535ff8196167:

[1.4.x] Fixed #11185 - Expanded docs on customizing widgets; thanks fadeev for the draft patch.

Backport of a73838fde33374573b8e765dfcb0225287d396c0 from master.

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