Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #8660 -- Small database query optimisation in User.get_profile.

When calling User.get_profile(), we now tell the profile object about the
related User object right away. This can save a database lookup later if
something in the user profile object wants to refer to the user object.

Patch from Mike Malone.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9152 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2f0be0faae2f10b6ae8c049e8469ab8404f9c7bf 1 parent 40904d0
Malcolm Tredinnick authored October 05, 2008

Showing 1 changed file with 1 addition and 0 deletions. Show diff stats Hide diff stats

  1. 1  django/contrib/auth/models.py
1  django/contrib/auth/models.py
@@ -291,6 +291,7 @@ def get_profile(self):
291 291
                 app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')
292 292
                 model = models.get_model(app_label, model_name)
293 293
                 self._profile_cache = model._default_manager.get(user__id__exact=self.id)
  294
+                self._profile_cache.user = self
294 295
             except (ImportError, ImproperlyConfigured):
295 296
                 raise SiteProfileNotAvailable
296 297
         return self._profile_cache

0 notes on commit 2f0be0f

Please sign in to comment.
Something went wrong with that request. Please try again.