﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7400	Auth: get_profile() doesn't allow other name than user for foreign key	contato@…	nobody	"Django's authentication framework get_profile() method doesn't allow another name than 'user' to foreign key field in user profile class, like:
{{{
class UserProfile(models.Model):
  another_name = models.ForeignKey(User, unique=True)
}}}

If I try to get the user profile with {{{user.get_profile()}}}, it generates an exception.

Error is in the get_profile method where it try to get the profile cache, getting by {{{self._profile_cache = model._default_manager.get(user__id__exact=self.id)}}}. The problem is {{{user__id__exact=self.id}}} where it had to be {{{anoter_name__id__exact=self.id}}} or anything else.
File django/contrib/auth/models.py:
{{{
    def get_profile(self):
        """"""
        Returns site-specific profile for this user. Raises
        SiteProfileNotAvailable if this site does not allow profiles.
        """"""
        if not hasattr(self, '_profile_cache'):
            from django.conf import settings
            if not settings.AUTH_PROFILE_MODULE:
                raise SiteProfileNotAvailable
            try:
                app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.')
                model = models.get_model(app_label, model_name)
                self._profile_cache = model._default_manager.get(user__id__exact=self.id) # <-- where error happens
            except (ImportError, ImproperlyConfigured):
                raise SiteProfileNotAvailable
        return self._profile_cache
}}}"		closed	Contrib apps	dev		wontfix			Unreviewed	0	0	0	0	0	0
