Skip to content

Commit

Permalink
Merge pull request #18 from jciskey/patch-1
Browse files Browse the repository at this point in the history
Fix typo and grammar
  • Loading branch information
shabda committed Feb 27, 2018
2 parents 7d92758 + 1cb1f57 commit e4e51bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/optimize_queries.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
How to optimize queries in Django admin?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

If you have a lot of calculated fields in your admin, you can be running multipel queries per object leading to your admin can becoming quite slow.
If you have a lot of calculated fields in your admin, you can be running multiple queries per object leading to your admin can becoming quite slow.
To fix this you can override the :code:`get_queryset` method on model admin to annotate the calculated fields.

Lets take the example of this :code:`ModelAdmin` we have for :code:`Origin`::
Expand All @@ -17,7 +17,7 @@ Lets take the example of this :code:`ModelAdmin` we have for :code:`Origin`::
return obj.villain_set.count()


This add two extra queries per row in your listview page. To fix this you can override the :code:`get_queryset` to annotate the counted fields,
This adds two extra queries per row in your listview page. To fix this you can override the :code:`get_queryset` to annotate the counted fields,
and then use the annotated fields in your ModelAdmin methods.

With the changes, your ModelAdmin field looks like this::
Expand Down

0 comments on commit e4e51bf

Please sign in to comment.