Skip to content

Commit

Permalink
Fixed #2189 -- Optimized auth.User.get_all_permissions() to use selec…
Browse files Browse the repository at this point in the history
…t_related behind the scenes to avoid multiple queries. Thanks, konrad@gwu.edu

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3162 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jun 20, 2006
1 parent 496d651 commit 551a027
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -74,6 +74,7 @@ answer newbie questions, and generally made Django that much better:
Cameron Knight (ckknight)
Bruce Kroeze <http://coderseye.com/>
Joseph Kocherhans
konrad@gwu.edu
lakin.wecker@gmail.com
Stuart Langridge <http://www.kryogenix.org/>
Eugene Lazutkin <http://lazutkin.com/blog/>
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/auth/models.py
Expand Up @@ -160,7 +160,7 @@ def get_group_permissions(self):
def get_all_permissions(self):
if not hasattr(self, '_perm_cache'):
import sets
self._perm_cache = sets.Set(["%s.%s" % (p.content_type.app_label, p.codename) for p in self.user_permissions.all()])
self._perm_cache = sets.Set(["%s.%s" % (p.content_type.app_label, p.codename) for p in self.user_permissions.select_related()])
self._perm_cache.update(self.get_group_permissions())
return self._perm_cache

Expand Down

0 comments on commit 551a027

Please sign in to comment.