[Answer]-Outputting Object to JSON instead of ID

1👍

I found that you can use Field Lookups to follow relationships and access fields in another related model:

import json
# ...
device_list = list(Device.objects.values('field1', 'field2', 'location__name', 'location__region'))
json.dumps(device_list)

The resulting JSON string:

[{field1": "value", "field2": "value", "location__name": "name", "location__region": "region"},
 {...}]

Leave a comment