UserProfile 扩展 user表 问题

guozhen037058 2013-11-25 01:07:29
定义扩展
class UserProfile(models.Model):
user = models.OneToOneField(User,unique=True)
leader=models.IntegerField()
def __unicode__(self):
return self.user.username

setting.py
AUTH_PROFILE_MODULE = 'updatesystemapp.UserProfile'


在admin中给leader添加值时,正常,但是在视图中访问扩展的leader字段时,报错
 username = request.POST.get('username', '')
password = request.POST.get('password', '')
user = auth.authenticate(username=username, password=password)
if user is not None and user.is_active:
auth.login(request, user)
print user.get_profile()
...................

报个错
UserProfile matching query does not exist.
我看网上好像也都是这么写的,怎么回事这是
...全文
134 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
屎克螂 2013-11-26
  • 打赏
  • 举报
回复
数据库里有没有leader这个列名,没有就对了。我也是新手不知道说的对不对

37,742

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧