Ticket #17863: patch_get_user_profile.diff

File patch_get_user_profile.diff, 1.2 KB (added by Henning Kage <henning.kage@…>, 13 years ago)

Method get_profile using db router

  • django/contrib/auth/models.py

    diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
    index 4e15849..cca5758 100644
    a b import urllib  
    22
    33from django.core.exceptions import ImproperlyConfigured
    44from django.core.mail import send_mail
    5 from django.db import models
     5from django.db import models, router
    66from django.db.models.manager import EmptyManager
    77from django.utils.crypto import get_random_string
    88from django.utils.encoding import smart_str
    class User(models.Model):  
    396396                    raise SiteProfileNotAvailable(
    397397                        'Unable to load the profile model, check '
    398398                        'AUTH_PROFILE_MODULE in your project settings')
    399                 self._profile_cache = model._default_manager.using(
    400                                    self._state.db).get(user__id__exact=self.id)
     399                db = router.db_for_read(model)             
     400                self._profile_cache = model._default_manager.using(db).get(
     401                    user__id__exact=self.id)
    401402                self._profile_cache.user = self
    402403            except (ImportError, ImproperlyConfigured):
    403404                raise SiteProfileNotAvailable
Back to Top