【发布时间】:2017-10-17 19:50:16
【问题描述】:
我有如下代码供人们登录:
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username=username, password=password)
if user:
# Check it the account is active
if user.is_active:
# Log the user in.
login(request, user)
我已扩展用户以创建用户配置文件。它包含其他信息。例如:地址、城市、州等。
如何从这种情况中提取用户配置文件?对于 Eclipse 下的 Java,如果我输入“user”,我会看到所有适用于对象“user”的 valid 方法。
PyCharm 似乎没有这样的功能。
话虽如此,如何找到与用户关联的个人资料信息?
TIA
以下是配置文件型号代码:
class UserProfileInfo (models.Model):
class Meta:
db_table = 'mstrauthdjprofile'
db_tablespace = 'PSAPUSR1001'
user = models.OneToOneField(User)
restrole = models.BigIntegerField(blank=True, null=True, default=0)
profilepic = models.ImageField(upload_to='profile_pics', blank=True)
lastpgprocno = models.BigIntegerField(blank=True, null=True, default=-1)
currentpgprocno = models.BigIntegerField(blank=True, null=True, default=-1)
nextpgprocno = models.BigIntegerField(blank=True, null=True, default=1)
reclocktype = models.BigIntegerField(blank=True, null=True, default=0)
reclockid = models.BigIntegerField(blank=True, null=True, default=0)
def __str__(self):
return self.user.username
【问题讨论】:
-
添加您的个人资料型号代码
-
@NeErAj KuMaR - 已将其添加到消息中。有什么想法吗?
-
尝试
user.userprofileinfo获取配置文件对象,第一个user应该是django默认用户实例
标签: python django pycharm profile