Django-allauth loads wrong base.html template
All of the answers provided force you to rewrite files and modify your own project to fit in with allauth, which is a completely unacceptable workflow. Such a third-party application should not have such manipulative power over your own project.
Truly, the easiest way to handle this situation, especially based on the answers provided, is to simply move the allauth app and its associated apps to the end of your INSTALLED_APPS
list in your settings.py
file. Django will find your base.html
template before it finds the other base.html
template in the other apps listed beneath it.
Problem solved.
Two years later this continues to be a problem and the accepted answer is missing some new information.
On github I discovered that all allauth templates derive from account/base.html, which derives from base.html. My solution was:
- In
virtualenv/lib/python2.7/sitepackages/django-allauth/templates
, copy the entire contents ofbase.html
to replace everything inaccount/base.html
(i.e. replace the{% extends 'base.html' %}
statement) - Delete allauth's
base.html
. It is now redundant.
Done!
Unless called directly, your base.html
is an extension of the templates that you define.
For example, if you render a template called Page.html
- at the top you will have {% extends "base.html" %}
.
When defined as above, base.html
is located in the path that you defined in your settings.py
under TEMPLATE_DIRS = ()
- which, from your description, is defined as project/template
.
Your best bet is to copy the django-allauth base.html
file to the defined TEMPLATE_DIRS
location, rename it to allauthbase.html
, then extend your templates to include it instead of your default base via {% extends "allauthbase.html" %}
.
Alternatively you could add a subfolder to your template location like project/template/allauth
, place the allauth base.html
there, and then use {% extends "allauth/base.html" %}
.
I had the opposite problem: I was trying to use my own base.html
file, but my Django project was grabbing the django-allauth
version of base.html
. It turns out that the order you define INSTALLED_APPS
in settings.py
affects how templates are rendered. In order to have my base.html
render instead of the one defined in django-allauth
, I needed to define INSTALLED_APPS
as the following:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# custom
'common',
'users',
'app',
# allauth
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]