2011-07-11 36 views
4

之后升级到1.3的Django(从1.2.3)后,以下行会导致系统崩溃:的Django 1.3:问题与用户配置升级

users = self.users.filter(userprofile__public_profile=True).order_by('first_name') 

所示的错误:

Caught FieldError while rendering: Cannot resolve keyword 'userprofile' into field. Choices are: _message_set, comment, commentabusereport, date_joined, dialog, dialogabusereport, email, first_name, forums, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, password, registrationprofile, user_permissions, userassociation, username, vote 

正如之前,该用户配置模型指定这样的:

AUTH_PROFILE_MODULE = 'emailuser.UserProfile' 

有趣的事情,某些字段显示为菱(如“对话框幷gabusereport“和”userassociation“)反过来是与UserProfile中的用户关系具有相同用户关系的其他内部模型。

任何可能导致这种情况的想法?为什么Django不能在这个关系中看到我们的UserProfile模型?

+0

有类似的问题,又回到Django的1.2.3和我的项目再次工作。希望我可以帮你解答 - 至少我可以为你的问题投票。 – golliher

+0

您是否有机会从配置文件的应用程序models.py文件中的django.contrib.auth.admin导入UserAdmin?可能是由这个问题引起的:https://code.djangoproject.com/ticket/15771 –

回答

1

如果你正试图从一个用户对象访问配置模式是不正确的符号:

user.get_profile() 

的用户配置模式应该是相反的FK关系到用户模式,所以是不能作为属性。

如果你想找到的所有用户配置对象,其中USERPROFILE =真由FIRST_NAME字段排序这将是:

userprofiles = UserProfile.objects.filter(public_profile=True).order_by('user__first_name')