Django allauth - 如何知道用户是否使用socialaccount或帐户登录?

时间:2017-03-19 07:13:15

标签: django django-templates django-allauth

如何知道用户是否使用socialaccount或帐户登录? 并在模板中获取此信息?

1 个答案:

答案 0 :(得分:0)

您可以使用模板标记:get_social_accounts

根据文件:

{% get_social_accounts user as accounts %}
Then:
    {{accounts.twitter}} -- a list of connected Twitter accounts
    {{accounts.twitter.0}} -- the first Twitter account
    {% if accounts %} -- if there is at least one social account

如果用户未与社交帐户关联:

{% if user.is_anonymous %}Not logged in.{% else %} Logged in.{% endif %}