﻿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
15771	"""from django.contrib.auth.admin import UserAdmin"" breaks backwards relations for User"	morgan.harris@…	nobody	"Importing the model UserAdmin from the package django.contrib.auth.admin breaks any backwards relations that exist on User. An example models.py:

{{{
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin

# Create your models here.

class UserProfile(models.Model):
	""""""Represents extra information on a user in the system""""""
	
	user = models.OneToOneField(User, related_name='profile')
	is_staff = models.BooleanField(default=False)
	is_external = models.BooleanField(default=False)
	faculty = models.CharField(max_length=255,blank=True)
}}}

and an example of the error in practice:


{{{
# python manage.py shell

Python 2.7 (r27:82508, Jul  3 2010, 21:12:11) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.
(InteractiveConsole)
>>> from usertest.users.models import *
>>> User.objects.filter(profile__faculty='Engineering')
Traceback (most recent call last):
 [...]
FieldError: Cannot resolve keyword 'profile' into field. Choices are: _message_set, date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser, last_login, last_name, password, user_permissions, username

}}}

If the class isn't imported, the result is thus:

{{{
# python manage.py shell

Python 2.7 (r27:82508, Jul  3 2010, 21:12:11) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.
(InteractiveConsole)
>>> from usertest.users.models import *
>>> User.objects.filter(profile__faculty='Engineering')
[]
}}}

This bug is new as of version 1.3."	Bug	closed	contrib.auth	1.3	Normal	wontfix			Unreviewed	0	0	0	0	0	0
