Code

Opened 4 years ago

Closed 20 months ago

Last modified 20 months ago

#13997 closed New feature (fixed)

Add an example of constructing a MultiWidget and document the value_from_datadict method

Reported by: cuci Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: paul.collins.iii@…, timograham@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I've been trying to get a multiwidget but I could only see some(old) example on net, none in official docs...preatty hard to do without docs.

Attachments (4)

13997.diff (2.1 KB) - added by prestontimmons 3 years ago.
Documented using the Multiwidget with single value fields
13997.2.diff (2.6 KB) - added by prestontimmons 3 years ago.
Modified the docs with better example and gave example usage.
13997.3.diff (3.2 KB) - added by prestontimmons 3 years ago.
13997.4.diff (10.1 KB) - added by timo 21 months ago.

Download all attachments as: .zip

Change History (19)

comment:1 Changed 4 years ago by thejaswi_puthraya

  • Component changed from Uncategorized to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by gabrielhurley

  • Triage Stage changed from Unreviewed to Accepted

One sentence certainly isn't all that should be said about MultiWidget. It probably warrants a whole "Constructing A MultiWidget" section at the end of that page, complete with explanation and an example.

comment:3 Changed 4 years ago by poswald

  • milestone set to 1.3

Changed 3 years ago by prestontimmons

Documented using the Multiwidget with single value fields

comment:4 Changed 3 years ago by prestontimmons

I added a patch with an example widget for using a MultiWidget with the us.forms.USPhoneNumberField in localflavor.

Changed 3 years ago by prestontimmons

Modified the docs with better example and gave example usage.

Changed 3 years ago by prestontimmons

comment:5 Changed 3 years ago by graham_king

  • Severity set to Normal
  • Type set to New feature

comment:6 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

comment:7 Changed 3 years ago by paulcollins

  • Cc paul.collins.iii@… added
  • Easy pickings unset
  • UI/UX unset

comment:8 Changed 2 years ago by mjdemilliano@…

  • Needs documentation set
  • Version changed from 1.2 to 1.4

It would be helpful if the documentation on MultiWidget also brought the method value_from_datadict to the attention, next to decompress, to also have the transformation from multiple widget values to the field value (decompress does the reverse).

Example:

def value_from_datadict(self, data, files, name):
    values = super(MyMultiWidget, self).value_from_datadict(data, files, name)
    # i.e. return MyValueType(float(values[0]), float(values[1]))
    return MyValueType(... something with values ...)

comment:9 Changed 22 months ago by timo

  • Has patch set
  • Needs documentation unset

comment:10 Changed 21 months ago by timo

  • Patch needs improvement set
  • Summary changed from multiwidget needs better docs to Add an example of constructing a MultiWidget and document the value_from_datadict method

We probably shouldn't use localflavor as an example at this point since it's being broken out into a separate package.

Changed 21 months ago by timo

comment:11 Changed 21 months ago by timo

  • Cc timograham@… added
  • Patch needs improvement unset

I've added a patch that combines the two existing MultiWidget sections, documents value_from_datadict, and adds an example MultiWidget with an explanation of each method.

comment:12 Changed 20 months ago by jezdez

  • Triage Stage changed from Accepted to Ready for checkin

Looks great!

comment:13 Changed 20 months ago by Tim Graham <timograham@…>

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

In 04775b4598d1a9c5bcc0c1da431e368f28dcd13e:

Fixed #13997 - Added an example of constructing a MultiWidget and documented the value_from_datadict method.

comment:14 Changed 20 months ago by Tim Graham <timograham@…>

In 31da2a5e56dba374279cc8276d9ccb2e3096e4a9:

[1.5.X] Fixed #13997 - Added an example of constructing a MultiWidget and documented the value_from_datadict method.

Backport of 04775b4598 from master

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

In 06c14a63a2c27e5eddfbd6f7b35bcb1d0fc2882b:

[1.4.X] Fixed #13997 - Added an example of constructing a MultiWidget and documented the value_from_datadict method.

Backport of 04775b4598 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.