Discussion:
Is it possible to get regular lists and dicts in renderer classes?
Hassan El-Mehalawi
2018-10-02 17:00:39 UTC
Permalink
I'm writing a DRF renderer that uses fastavro
<https://github.com/fastavro/fastavro> to render data. I'm running into a
problem with the types that fastavro expects. Fastavro seems to only accept
dicts and lists (I'm assuming because it's implemented in Cython), but in
the render method, I'm getting OrderedDict and ReturnList instead. This
causes a crash since fastavro is getting the wrong types. I wrote this
return dict({k: convert_types(v) for k, v in data.items()})
return list([convert_types(v) for v in data])
return data
This solves the crash but it's really not ideal. It's quite a bit of data
(which is why I'm using avro in the first place), and iterating through it
all and using up memory to copy values is not going to fly. Is there a way
to get DRF to send me just regular dicts and lists in the render method?
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...