Templates ========= Introduction ------------ The templates that are offered out of the box are intentionally plain and without any styling. We do not want to pick a side in the multitudes of frontend styling options out there, and the look and feel typically should be adjusted to match the branding of your project. Therefore it is recommended that you copy all templates over to your own project and adjust them as you see fit. Having said that, over time the years the complexity of authentication grew considerably. For example, with features such as third party account providers and two-factor authentication adjusting the templates involves a lot more than just styling a ``login.html`` and a ``signup.html`` template. Therefore, a mechanism is included that allows you to adjust the look and feel of all templates by only overriding a few core templates. This approach allows you to achieve visual results fast, but is of course more limited compared to styling all templates yourself. Overriding the Built-In Templates --------------------------------- The ``allauth`` app includes all templates, and can be found in the `allauth/templates `__ directory. When ``allauth`` is part of your ``INSTALLED_APPS``, and ``"APP_DIRS": True`` is configured, Django will be able to find its templates. As ``DIRS`` is searched before ``APP_DIRS``, overriding the templates involves adding an entry to ``DIRS`` that points to your a project specific template folder, as follows:: from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [ BASE_DIR / "templates" ], "APP_DIRS": True, "OPTIONS": { "context_processors": [ "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", ], }, }, ] If you copy over all templates to your ``BASE_DIR / "templates"`` it should contain these entries (a.o.): - An ``account`` folder containing the templates from the ``allauth.account`` app. - A ``socialaccount`` folder containing the templates from the ``allauth.socialaccount`` app. - A ``mfa`` folder containing the templates from the ``allauth.mfa`` app. - An ``allauth`` folder containing the overall styling templates (see the next section). Styling the Existing Templates ------------------------------ Instead of copying all templates, a mechanism is included that allows you to adjust the look and feel of all templates by only overriding a few core templates. This approach allows you to achieve visual results fast, but is of course more limited compared to styling all templates yourself. Layouts ^^^^^^^ The existing templates use two base page layouts: - The entrance layout: These are all pages where the user is in the process of authenticating, such as the login and signup pages. - The account management layout: The pages where an authenticated user can manage the account, such as changing the email address or password. You can alter these layouts by providing these templates in your own project: ========================================== =========== Template file Description ========================================== =========== allauth/layouts/base.html The overall base template. allauth/layouts/entrance.html The entrance template, extending the base template. allauth/layouts/manage.html The account management template, extending the base template. ========================================== =========== Elements ^^^^^^^^ When rendering e.g. a Bootstrap button you would typically use:: Yet, when a different CSS framework is used other class names apply, and possibly even other markup. Therefore, the built-in templates do not include the above content directly. Instead of referring to tags such ``