I am using DRF and i have a situation where I have too many database calls.
So I used `values()` for one of the serializers to reduce the number of calls. I tweeted about it as well https://twitter.com/KimStacks/status/1190942972273025024 I am of course not sure if this is the best way to solve it. In Tom Christie's piece he mentioned about using values here https://www.dabapps.com/blog/api-performance-profiling-django-rest-framework/ I quote >4. You don't always need to use serializers. > >For performance critical views you might consider dropping the serializers entirely and simply use .values() in your database queries. If you're using hyperlinked representations or other complex fields you might find you also need to do some post processing on the data structures before returning them in the response. REST framework is designed to make this easy. Ok so far so good. One API i have issues with went from 800+ database queries to 16. I consider that a success. Then, when I run my unit tests, things fail. Why? Because the datetime format expected was wrong. So I used DRF's own JSOEncoder which fixed this issue but broke another thing. I also have decimal values which usually converts to STRING because of the default COERCE_DECIMAL_TO_STRING setting. See https://github.com/encode/django-rest-framework/blob/b26db128135fcd10c890213d8d56af8cf0a171a0/docs/api-guide/settings.md#coerce_decimal_to_string Now unfortunately this setting applies the coercion at the serializer level. Not the encoder level. SO if i use `JSONEncoder().default(this_is_a_decimal)` i will get back float. Not string. So I had to write my own encoder. https://gist.github.com/simkimsia/ab96a26bcb3a735fa416c33d75e576db My question is is this something that can be improved within the DRF library? if so, I will be happy to send a PR. I wasn't sure and I didn't want to pollute the github issues hence i posted here for advice. Thank you -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/22ccac51-6f73-4723-b51d-0287f317a6d5%40googlegroups.com.