Move customized django-allauth templates to directory other than 'account'

277 views Asked by At

I set up django-allauth correctly following the project's documentation. I wanted to override the look and feel of the django-allauth templates so I went to the project github and downloaded the django-allauth templates folder into my accountsapp/templates directory.

My problem is that django-allauth will only look for its templates in the templates/account folder.

I want to put my templates in the templates/allauth/account folder to help keep MY template files separate from django-allauth's template files.

When I do this, django-allauth is unable to find the templates that I customized.

Here is my project structure:

projectfolder/
    accountsapp/
        templates/

    projectsettings/
        settings.py
    manage.py

What I've tried:

  1. Setting my TEMPLATES 'DIRS' to this

    'DIRS': [ os.path.join(os.path.dirname(BASE_DIR), 'accountsapp', 'templates', 'allauth'), ],
    

    With BASE_DIR being this: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))). This works, but I'm not sure that this is the best practice/solution to my problem.

1

There are 1 answers

0
Alasdair On BEST ANSWER

If you put your templates in projectfolder/accountsapp/templates/, then the app directories loader will find them, as long as you have 'APP_DIRS': True in your template settings.

However, if you move the templates into the projectfolder/accountsapp/templates/allauth subfolder, then the app directories loader will not find them, so you will have to add the directory to DIRS as you have already done.