How to access the user profile in a Django template?

前端 未结 6 1714
滥情空心
滥情空心 2020-11-30 21:05

I\'m storing some additional per-user information using the AUTH_PROFILE_MODULE.

We can access the user in a Django template using {{ request.user }} bu

6条回答
  •  天涯浪人
    2020-11-30 21:34

    If it helps anyone, I used the followings in my template:

    Username: {{ user.username }}

    User Full name: {{ user.get_full_name }}

    User Group: {{ user.groups.all.0 }}

    Email: {{ user.email }}

    Session Started at: {{ user.last_login }}

    A sample result is like this:

    User: auditor ezio

    User Group: auditGroup

    Username: testUser03

    Email: testuser03@auditor.com

    Session Started at- April 16, 2018, 9:38 p.m.

    Thanks :)

提交回复
热议问题