|
You are here |
stribny.name | ||
| | | | |
www.mattlayman.com
|
|
| | | | | If you use Django REST Framework and the DRF JSON API extension, you may want to learn how to sideload extra resources to save on network requests of commonly paired models. We will explore the extra settings required to make that happen. | |
| | | | |
davi.sh
|
|
| | | | | I often want to include related nested objects in my Django REST Framework ModelViewSets for CRUD operations, but don't want those related objects cluttering up the list view. To accomplish this, you can return a serializer from get_serializer_class() that doesn't include the nested relation when the ViewSet action is list. I ended up doing this on a bunch of viewsets, so I factored the logic out into a separate mixin: from typing import Union from rest_framework import viewsets class ListSerializerMixi.... | |
| | | | |
www.laceyhenschel.com
|
|
| | | | | If you came here from Part 1 of What You Should Know About Django REST Framework, you may be wondering why I just walked you through a bunch of source code. We stepped through that code because if you know what the main methods of the ModelViewSet do and how they work, you know where to go when you want to tweak the behavior of your viewset. You can pull out the method that contains what you want to change, override it with your own custom behavior, and put it back in. In Part 1, we were writing a BookViewSet. So let's go through a few cases where we might want to customize the behavior of our endpoints and walk through how we would do that. | |
| | | | |
www.peter-cohen.com
|
|
| | | This week on Space Javelin we talked Apple financials, iPhone 12 speculation, and I went on an extended rant about the sorry state of Mac gaming. | ||