How to get the currently logged in user's user id in Django?

前端 未结 5 1024
情书的邮戳
情书的邮戳 2020-12-12 11:34

How to get the currently logged-in user\'s id?

in models.py:

class Game(models.model):
    name = models.CharField(max_length=255)
    o         


        
5条回答
  •  鱼传尺愫
    2020-12-12 12:05

    FOR WITHIN TEMPLATES

    This is how I usually get current logged in user and their id in my templates.

    Your Username is : {{user}}

    Your User Id is : {{user.id}}

提交回复
热议问题