Search code examples
djangodjango-templatesdjango-allauth

How to edit django-allauth default templates?


i'm using Django 1.10 and i want to add the allauth's app for login, signin, etc, to my website. I've installed allauth from pip, and tried to put the templates from allauth repository inside my templates folder and call them but i don't know how to make it work.


Solution

  • The correct answer can be found here: https://stackoverflow.com/a/31282443/4992248

    1. Create yourproject/templates/allauth/account/ and paste here all templates you need to edit from /myproject/Lib/site-packages/allauth/templates/account.

    If you need to make changes for socialaccount templates, create also yourproject/templates/allauth/socialaccount/

    1. Edit 'DIRS' in settings.py like 'DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'templates', 'allauth')],

    In the end it should look somethink like this:

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'templates', 'allauth')],
            'APP_DIRS': True,
            'OPTIONS': {
                'debug': False,
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.template.context_processors.media',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
                ],
            },
        },
    ]
    
    1. You never should do any code changes at /Lib/site-packages/*, because all changes are lost once a package is updated.