| 4 | class 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 | |