Code

Opened 5 years ago

Closed 19 months ago

Last modified 19 months ago

#11185 closed Cleanup/optimization (fixed)

Document how to customize widgets

Reported by: bensmith Owned by: timo
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 3 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 timo 20 months ago.
Updated parts of fadeev that are still applicable

Download all attachments as: .zip

Change History (17)

comment:1 Changed 5 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by bjunix

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

comment:3 Changed 3 years ago by poswald

  • milestone set to 1.3

comment:4 Changed 3 years ago by fadeev

  • Cc fadeev added
  • Owner changed from nobody to fadeev

Changed 3 years ago by fadeev

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 Changed 3 years ago by fadeev

  • Resolution set to worksforme
  • Status changed from new to 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 Changed 3 years ago by russellm

  • Has patch set
  • Resolution worksforme deleted
  • Status changed from closed to 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 Changed 3 years ago by dmclain

  • Easy pickings unset
  • Severity set to Normal
  • Type set to 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 Changed 3 years ago by julien

  • Type changed from Uncategorized to Cleanup/optimization

comment:9 Changed 3 years ago by julien

  • 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 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

comment:11 Changed 20 months ago by timo

  • Cc timograham@… added
  • Owner changed from fadeev to timo
  • Status changed from reopened to new

I'm working on updating the patch from fadeev

Changed 20 months ago by timo

Updated parts of fadeev that are still applicable

comment:12 Changed 20 months ago by timo

  • Patch needs improvement unset

comment:13 Changed 19 months ago by claudep

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 Changed 19 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In a73838fde33374573b8e765dfcb0225287d396c0:

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

comment:15 Changed 19 months ago by Tim Graham <timograham@…>

In 1b5b8b874fb79a8d2b2bc7ca8f93535ff8196167:

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

Backport of a73838fde33374573b8e765dfcb0225287d396c0 from master.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.