drf-fast-serializer
drf-fast-serializer copied to clipboard
Note potential for differences in output representation.
Because these optimisations don't call into the field to_representation there's potential for them to end up with differing output representations, particularly when used with ujson.
Likely areas of differing representations include:
- date/time/datetime formats.
- decimals, wrt output precision and also float vs string representations.
- FileField and ImageField outputs (assume we'll get path outputs, instead of typical URLs)
- Relationships (Havn't checked, presume you'll always get pk representations, or perhaps they don't work)
- URL identity fields (Wont work, unless the model has a
urlproperty) - SerializerMethodField (Won't work)
- Nested relationships (Won't work)
Eg.
>>> ujson.dumps({'published':datetime.datetime.now()})
'{"published":1414663411}'
>>> ujson.dumps({'total_cost':decimal.Decimal('1.23')})
'{"total_cost":1.23}'
The implementations do call field.to_representation (see https://github.com/akaariai/drf-fast-serializer/blob/master/fast_serializer/init.py#L28). What ujson does differently is a bit out of scope for my work, but still worth pointing out in the readme.