-
Notifications
You must be signed in to change notification settings - Fork 6
Issue with ThumbnailerImageField (ImageField?) #13
Comments
Hi @hauru. preserialize does not actually encode the data into JSON. It simply creates a data structure based on the arguments in the serialize function. So, if the types in the data structure cannot be encoded by the Django JSON encoder (and therefore the standard library decoder), then the encode may need to be extended to support this type. |
Yeah, sorry for that. Thanks for the quick response. Actually i know it isn't supposed to serialize into JSON but it was late yesterday when i was testing it and, as it turns out, my mind was far from being clear. What i did was to drop-in replace my own serializer, which also converts model instances to regular Python dictionaries. Resulting data is JSON-encoded later with a different function call (using Django's own encoder). I guess what i was expecting from preserialize was the output dictionary values to be plain Python objects. In case of an |
No problem at all.
I understand the expectation. However, since arbitrary fields could be defined on a model it would be impossible to account for all cases. That being said, a possible approach would be to coerce objects to a primitive based on it's internal type. One way of handling this right now, is to use a |
The coercion could use the |
That's what i eventually end up doing. Well, more or less. In my case the difficulty with Thanks once again! |
I have a couple of improvements in the works. #14 defines the On a side note, some of the CI tests are failing due to Django's |
Looks like I figured it out. I was not calling |
Hi,
I'm using Easy Thumbnails for managing resized versions of images. In my model i have a ThumbnailerImageField which stores a URL to the original image. When trying to serialize an instance of this model, i get the JSON exception:
<ThumbnailerImageFieldFile: ...> is not JSON serializable
ThumbnailerImageField
extends Django's originalImageField
and the Django-provided serialization mechanism works well in this case so i guess it may be a bug.The text was updated successfully, but these errors were encountered: