How to optimize Django's model's string representation database hits in browsable API #9119
Unanswered
HansBambel
asked this question in
Question & Answer
Replies: 1 comment 3 replies
-
Hello there! |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am currently trying to optimize my API and noticed that the browsable API is responsible for N+1 queries. This only happens when I add the parent-class in the child's
__str__
method.Comparison using django-debug-toolbar:
My (simplified) models are the following:
This is the view:
I have also tried using select_related("client") in the view, but this did not help. It seems like the browsable API is not using the view's queryset.
How can I make the browsable API make more efficient? Is that even possible?
Beta Was this translation helpful? Give feedback.
All reactions