1👍
✅
Since address
is stored as models.TextField()
and retrieved as Python str
in the model:
- In
MultiWidget
decompress
, load fromstr
:
class AddressWidget(MultiWidget):
...
def decompress(self, value):
if value:
return json.loads(value)
return (None, None, None, None, None)
- In
MultiValueField
compress
, dump tostr
:
class AddressField(MultiValueField):
...
def compress(self, value_list):
if value_list:
return json.dumps(value_list)
return ''
Source:stackexchange.com