Templates¶
Overridable templates¶
allauth
ships many templates, viewable in the
allauth/templates
directory.
For instance, the view corresponding to the account_login
URL uses the
template account/login.html
. If you create a file with this name in your
code layout, it can override the one shipped with allauth
.
Template Tags¶
The following template tag libraries are available:
account
: tags for dealing with accounts in generalsocialaccount
: tags focused on social accounts
Account Tags¶
Use user_display
to render a user name without making assumptions on
how the user is represented (e.g. render the username, or first
name?):
{% load account %}
{% user_display user %}
Or, if you need to use in a {% blocktrans %}
:
{% load account %}
{% user_display user as user_display %}
{% blocktrans %}{{ user_display }} has logged in...{% endblocktrans %}
Then, override the ACCOUNT_USER_DISPLAY
setting with your project
specific user display callable.
If you set ACCOUNT_USERNAME_REQUIRED = False
and ACCOUNT_USER_MODEL_USERNAME_FIELD = None
,
then you can simply display the user.email with {{ user }}:
In case you forgot, your username is {{ user }}.
Social Account Tags¶
Use the
provider_login_url
tag to generate provider specific login URLs:Here, you can pass along an optional
process
parameter that indicates how to process the social login. You can choose betweenlogin
andconnect
:Furthermore, you can pass along an
action
parameter with valuereauthenticate
to indicate that you want the user to be re-prompted for authentication even if they already signed in before. For now, this is supported by Facebook, Google and Twitter only.For Javascript based logins (e.g. when you enable the Facebook JS SDK), you will need to make sure that the required Javascript is loaded. The following tag loads all scripts for the enabled providers:
For easy access to the social accounts for a user use:
Then:
Finally, social authentication providers configured for the current site can be retrieved via:
Which will populate the
socialaccount_providers
variable in the template context with a list of configured social authentication providers. This supersedes the context processor used in version 0.21 and below.