Using django 1.8.4, I'm getting the following error when trying to serialize a FileField:
<FieldFile: sampleapp/img5_L3sBxJI.png> is not JSON serializable
Traceback:
[...]
File "/home/vagrant/.venvs/infra_env/local/lib/python2.7/site-packages/swampdragon/models.py" in save
self._publish(self.action, self.changed_fields)
File "/home/vagrant/.venvs/infra_env/local/lib/python2.7/site-packages/swampdragon/models.py" in _publish
publish_model(self, self._serializer, action, changed_fields)
File "/home/vagrant/.venvs/infra_env/local/lib/python2.7/site-packages/swampdragon/pubsub_providers/model_publisher.py" in publish_model
publisher.publish(c, publish_data)
File "/home/vagrant/.venvs/infra_env/local/lib/python2.7/site-packages/swampdragon/pubsub_providers/redis_publisher.py" in publish
get_redis_cli().publish(channel, json.dumps(message))
File "/usr/lib/python2.7/json/init.py" in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/json/encoder.py" in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py" in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py" in default
raise TypeError(repr(o) + " is not JSON serializable")
Exception Type: TypeError at /admin/mapping/tile/5/
Exception Value: <FieldFile: sampleapp/img5_L3sBxJI.png> is not JSON serializable
Using django 1.8.4, I'm getting the following error when trying to serialize a FileField: <FieldFile: sampleapp/img5_L3sBxJI.png> is not JSON serializable Traceback: [...] File "/home/vagrant/.venvs/infra_env/local/lib/python2.7/site-packages/swampdragon/models.py" in save
Exception Type: TypeError at /admin/mapping/tile/5/ Exception Value: <FieldFile: sampleapp/img5_L3sBxJI.png> is not JSON serializable
The problem seems to be in https://github.com/jonashagstedt/swampdragon/blob/master/swampdragon/serializers/field_serializers.py#L34 we're checking if type of of the 'value' is a FileField, but it's actually a FieldFile as described in the traceback above and explained at https://docs.djangoproject.com/en/1.8/ref/models/fields/#filefield-and-fieldfile.
Hence, I think we should be using FileSerializer in the case where value is a FieldFile as well.