Changes between Initial Version and Version 3 of Ticket #28443


Ignore:
Timestamp:
Jul 28, 2017, 3:23:57 AM (7 years ago)
Author:
adam-kral
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28443

    • Property Component UncategorizedForms
    • Property Type UncategorizedBug
    • Property Resolutionneedsinfo
    • Property Status newclosed
  • Ticket #28443 – Description

    initial v3  
    22
    33{{{#!python
     4class AddressInput(widgets.MultiWidget):
     5    def __init__(self, attrs=None):
     6        self.widgets = widgets.HiddenInput(attrs), widgets.TextInput(attrs). # note that the second widget would be customized, I'm only providing simplified example, which does produce the same error
     7        super().__init__(self.widgets, attrs)
     8
     9    def decompress(self, value):
     10        try:
     11            address = AddressPoint.objects.get(pk=value)
     12        except (AddressPoint.DoesNotExist, ValueError):
     13            address = None
     14
     15        return [value, str(address)]
     16
     17    def value_from_datadict(self, data, files, name):
     18        return tuple(widget.value_from_datadict(data, files, f'{name}_{i}') for i, widget in enumerate(self.widgets))
     19
     20
    421class AddressFormField(MultiValueField):
    522    widget = AddressInput
Back to Top