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

Django allauth-如何知道用户是否使用socialaccount或帐户登录?,django,django-templates,django-allauth,Django,Django Templates,Django Allauth,如何知道用户是否使用socialaccount或account登录? 并在模板中获取此信息?您可以使用模板标签:获取社交账户 根据文件: {% get_social_accounts user as accounts %} Then: {{accounts.twitter}} -- a list of connected Twitter accounts {{accounts.twitter.0}} -- the first Twitter account {% if a

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

您可以使用模板标签:
获取社交账户

根据文件:

{% 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 %}

我找到了这个解决方案,我不知道是否是最好的解决方案,但它是有效的,在socialaccount中创建一个上下文并执行以下查询:
if-socialaccount.objects.filter(user\u id=request.user).exists():…