I've been trying to get django-allauth working for a couple days now and I finally found out what was going on.
Instead of loading the base.html
template that installs with django-allauth, the app loads the base.html
file that I use for the rest of my website.
How do i tell django-allauth to use the base.html template in the virtualenv/lib/python2.7/sitepackages/django-allauth
directory instead of my project/template
directory?
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'),
]
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" %}
.
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:
virtualenv/lib/python2.7/sitepackages/django-allauth/templates
, copy the entire contents of base.html
to replace everything in account/base.html
(i.e. replace the {% extends 'base.html' %}
statement)base.html
. It is now redundant.Done!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With