code: def get_social_accounts(user):
      
      accounts = {}
      for account in user.socialaccount_set.all().iterator():
          providers = accounts.setdefault(account.provider, [])
          providers.append(account)
      return accounts
docs: {% 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