Skip to content

Tags

#django

Posts tagged #django on Dynamo Geeks: 2 posts from the community, most useful first.

2 posts

Posts tagged #django

  1. Question

    Django REST Framework: still N+1 queries after select_related, what am I missing?

    One of my mentees brought this to me and now I am also stuck, which is humbling. We have a simple endpoint listing courses. Each course has a teacher (ForeignKey) and many tags (ManyToMany), and the serializer also shows how many students are enrolled. class CourseSerializer(serializers.ModelSerializer): teacher = TeacherSerializer() tags = TagSerializer(many=True) student_count = serializers.SerializerMethodField()…

    Grace Wanjiru4likes3comments

  2. Question

    Django endpoint does 300+ queries, select_related vs prefetch_related confusion

    Hi, I am intern at a fintech, writing internal API in Django REST Framework. Endpoint /api/transfers/ returns 50 transfers and django-debug-toolbar shows 312 queries xD Models: Transfer has two ForeignKeys to Account (sender, receiver), Account has ForeignKey to Customer , and Transfer has ManyToMany tags . class TransferViewSet(viewsets.ReadOnlyModelViewSet): queryset = Transfer.objects.select_related("sender",…

    Kacper Nowicki13likes9comments

Get the best of Dynamo Geeks weekly

One email each Monday with the most useful posts. No spam; unsubscribe in one click.