Wait, where’s my pineapple?

Multiple serializers vs multiple views in Django Rest Framework

Photo by engin akyurt on Unsplash

Brief introduction

https://gist.github.com/ewelina29/c025651c47948e46e630dbbf1d4e211b
https://gist.github.com/ewelina29/86f4492aa832fe65aa20c4aa6316aa16
https://gist.github.com/ewelina29/f4e2dfc0d5e664cd8088231fbca44e40
https://gist.github.com/ewelina29/3ba603e239e383d794c027f914435036
{
"name": "Hawaiian",
"price": 29.99,
"sauce": 1,
"ingredients": [1,2,5]
}
Response of the GET request

Multiple views — multiple serializers

https://gist.github.com/ewelina29/ada20176e8230e519c8913e7598076fe
https://gist.github.com/ewelina29/2d85154150efb213817472971689f233
https://gist.github.com/ewelina29/810a907e956c77e9770971f3013674aa

One view — one serializer

https://gist.github.com/ewelina29/bc1a789b965a72747d6f50f67d63da4c

One view — multiple serializers

https://gist.github.com/ewelina29/d4bf88c1215feb99286f1e369d50caa5
https://gist.github.com/ewelina29/3c415961609a79fa185577a14e3b4fd6
https://gist.github.com/ewelina29/e9cb1c26cee1046710a9d68c2f026b2d

Conclusion

Passionate about programming and writing :). I work as a software developer, mostly in Django and ReactJS. You can reach me here: https://pogromcykodu.pl

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store