Commit e4e208b9caa65df928288758813ad1eff01955e2
1 parent
e2d764da
Limited user queries when appropriate
Fixes #48.
Showing
2 changed files
with
4 additions
and
3 deletions
| @@ -91,7 +91,8 @@ class BaseCommentNode(template.Node): | @@ -91,7 +91,8 @@ class BaseCommentNode(template.Node): | ||
| 91 | qs = qs.filter(is_public=True) | 91 | qs = qs.filter(is_public=True) |
| 92 | if getattr(settings, 'COMMENTS_HIDE_REMOVED', True) and 'is_removed' in field_names: | 92 | if getattr(settings, 'COMMENTS_HIDE_REMOVED', True) and 'is_removed' in field_names: |
| 93 | qs = qs.filter(is_removed=False) | 93 | qs = qs.filter(is_removed=False) |
| 94 | - | 94 | + if 'user' in field_names: |
| 95 | + qs = qs.select_related('user') | ||
| 95 | return qs | 96 | return qs |
| 96 | 97 | ||
| 97 | def get_target_ctype_pk(self, context): | 98 | def get_target_ctype_pk(self, context): |
| @@ -154,11 +154,11 @@ class CommentTemplateTagTests(CommentTestCase): | @@ -154,11 +154,11 @@ class CommentTemplateTagTests(CommentTestCase): | ||
| 154 | 154 | ||
| 155 | # Clear CT cache | 155 | # Clear CT cache |
| 156 | ContentType.objects.clear_cache() | 156 | ContentType.objects.clear_cache() |
| 157 | - with self.assertNumQueries(4): | 157 | + with self.assertNumQueries(3): |
| 158 | self.testRenderCommentListFromObject() | 158 | self.testRenderCommentListFromObject() |
| 159 | 159 | ||
| 160 | # CT's should be cached | 160 | # CT's should be cached |
| 161 | - with self.assertNumQueries(3): | 161 | + with self.assertNumQueries(2): |
| 162 | self.testRenderCommentListFromObject() | 162 | self.testRenderCommentListFromObject() |
| 163 | 163 | ||
| 164 | # {% get_comment_list %} -------------------- | 164 | # {% get_comment_list %} -------------------- |
Please
register
or
login
to post a comment