mirror of https://github.com/django/django.git
Fixed #2189 -- Optimized auth.User.get_all_permissions() to use select_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
This commit is contained in:
parent
496d651546
commit
551a0272e6
1
AUTHORS
1
AUTHORS
|
@ -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/>
|
||||
|
|
|
@ -160,7 +160,7 @@ class User(models.Model):
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue