Login

Tag "Standartization"

Snippet List

Django Standard API Response Middleware for DRF for modern frontend easy usage

I'm typescript frontend developer and i was interested in standartizing API server responses. I've tried Django for one of my projects. I've build my API and splited it into Django apps aiming at possible migration to [link >] [Microservices](https://www.youtube.com/watch?v=0iB5IPoTDts) [<] later. The problem I've faced is a difficulty of standartization API responses not only in multiple views, but for all composition of JSON-oriented django-apps which can only be made with middleware. I have put all the links to everybody could familiarize with Django framework conceptions used here. Also, I suggest to familiarize with [link >] [origin solution] (https://djangosnippets.org/snippets/10717/) [<]. The main difference is that in all my DRF JSONRenderers I do not need to wrap fields in 'result' or 'results' nested JSON. I do not get messed with result and results. If I expect an array, I just check additional pagination fields. I did not used a pagination section in my project, still i've left opportunities for that according to [link >] [origin solution] (https://djangosnippets.org/snippets/10717/) [<. Ypu can also find a paginator code fro DRF there.

  • Django
  • DRF
  • Standartization
  • Middlewares
  • Microservices
Read More

1 snippet posted so far.