Python 如何从DJango中的用户处获取配置文件

Python 如何从DJango中的用户处获取配置文件,python,django,pycharm,profile,Python,Django,Pycharm,Profile,对于登录的用户,我有如下代码: 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_act

对于登录的用户,我有如下代码:

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)
我已经扩展了用户以创建一个UserProfile。它包含其他信息。地址、城市、州等

如何从这种情况中提取用户配置文件?对于Eclipse下的Java,如果我输入“user”,我将看到应用于对象“user”的所有有效方法

PyCharm似乎没有这样的功能

话虽如此,如何才能找到与用户关联的配置文件信息

短暂性脑缺血发作

以下是配置文件型号代码:

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

OneToOneField
s始终可从其对应位置访问

user = authenticate(username=username, password=password)
user.userprofileinfo

user = User.objects.first()
user.userprofileinfo

user_profile_info = UserProfileInfo.objects.first()
user_profile_info.user
您可以通过在代码中插入断点来使用pdb之类的调试器(我认为PyCharm应该有一种自动处理方法):

这将允许您与当前范围交互。您可以使用
\uuuu dict\uuuu

user.__dict__
{'username': 'user', 'id': 1, ...}

还考虑一个更强大的/交互式的调试器,比如IPython或Bython,它内置了自动完成。

<代码> OnOnfield Field/Cult>S总是可以从它们的对应物访问。

user = authenticate(username=username, password=password)
user.userprofileinfo

user = User.objects.first()
user.userprofileinfo

user_profile_info = UserProfileInfo.objects.first()
user_profile_info.user
您可以通过在代码中插入断点来使用pdb之类的调试器(我认为PyCharm应该有一种自动处理方法):

这将允许您与当前范围交互。您可以使用
\uuuu dict\uuuu

user.__dict__
{'username': 'user', 'id': 1, ...}

还考虑一个更强大的/交互式的调试器,比如IPython或Bython,它内置了自动完成。code@NeErAj库马尔-已将其添加到消息中。有什么想法吗?尝试

user.userprofileinfo
获取配置文件对象,首先
user
应该是django默认用户实例添加配置文件模型code@NeErAj库马尔-已将其添加到消息中。有什么想法吗?尝试
user.userprofileinfo
获取配置文件对象,第一个
user
应该是django默认用户实例