#31722: RangeWidget produces 1 subwidget, itself
-------------------------------------+-------------------------------------
     Reporter:  Ryan Heard           |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  closed
    Component:  Uncategorized        |                  Version:  3.0
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  MultiWidget          |             Triage Stage:
  RangeWidget Widget                 |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 You need to drill down further to access the child widgets.

 `form.date_range` is a BoundField. `subwidgets` returns the single item
 list of the BoundWidget wrapping your RangeWidget, which is a MultiWidget
 subclass. The RangeWidget has a `widgets` property containing the child
 widgets you're after.

 As
 
[https://docs.djangoproject.com/en/3.0/ref/forms/widgets/#django.forms.MultiWidget.get_context
 per the multi widget docs] RangeWidget will add `subwidgets` to the
 context to be used by the **widget template**:

 {{{
 >>>f["a_range"].subwidgets[0].parent_widget.get_context('a_range', '',
 {})["widget"]["subwidgets"]
 [{'name': 'a_range_0', 'is_hidden': False, 'required': False, 'value':
 None, 'attrs': {}, 'template_name': 'django/forms/widgets/number.html',
 'type': 'number'}, {'name': 'a_range_1', 'is_hidden': False, 'required':
 False, 'value': None, 'attrs': {}, 'template_name':
 'django/forms/widgets/number.html', 'type': 'number'}]
 }}}

 It's that that can be iterated as you're intending. Please see
 TicketClosingReasons/UseSupportChannels.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31722#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.3e3036dbfd55a859af9285ad04c3df07%40djangoproject.com.

Reply via email to