Differentiate between null and missing fields
mainIn API responses, a field that is explicitly null or missing entirely will both result in None in Python. To distinguish them, check the .model_fields_set attribute on the response object.
if response.my_field is None:
if 'my_field' not in response.model_fields_set:
print('Field was missing from JSON')
else:
print('Field was explicitly null in JSON')