Objects with DatetimeField attributes cannot be properly serialised when any of their DatetimeField attributes is not set (i.e. set to null in the JSON response). This makes the following scenario possible:
fetch data from the server (e.g. TembaClient(...).get_runs()) - the data is internally deserialised by rapidpro-python
fed the result of this deserialisation process back to rapidpro-python to have it (re)serialised
error (please see the example traceback below)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ego/.virtualenvs/rapidpro-python/local/lib/python2.7/site-packages/temba_client/serialization.py", line 63, in serialize
field_value = field.serialize(attr_value)
File "/home/ego/.virtualenvs/rapidpro-python/local/lib/python2.7/site-packages/temba_client/serialization.py", line 148, in serialize
return [self.item_class.serialize(item) for item in value]
File "/home/ego/.virtualenvs/rapidpro-python/local/lib/python2.7/site-packages/temba_client/serialization.py", line 63, in serialize
field_value = field.serialize(attr_value)
File "/home/ego/.virtualenvs/rapidpro-python/local/lib/python2.7/site-packages/temba_client/serialization.py", line 122, in serialize
return format_iso8601(value)
File "/home/ego/.virtualenvs/rapidpro-python/local/lib/python2.7/site-packages/temba_client/utils.py", line 40, in format_iso8601
return six.text_type(value.astimezone(pytz.UTC).strftime(_format))
AttributeError: 'NoneType' object has no attribute 'astimezone'
Objects with DatetimeField attributes cannot be properly serialised when any of their DatetimeField attributes is not set (i.e. set to null in the JSON response). This makes the following scenario possible: