Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Allauth Error: "'socialaccount' is not a registered tag library"

I'm following the instructions for using django-allauth as shown here. I'm not interested in using social authentication - just a simple email and password signup flow. For some reason, when I go to /accounts/login/ I get the error

TemplateSyntaxError at /accounts/login/
'socialaccount' is not a registered tag library. Must be one of:
account
account_tags
...

enter image description here

In my settings.py I have

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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',
            ],
        },
    },
]


# Required by allauth
AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',

    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
)


# Application definition
INSTALLED_APPS = [
    # My apps
    'trinalysis_app.apps.TrinalysisAppConfig',

    # Third party apps
    'django.contrib.sites', # Django app required for using allauth
    'allauth',
    'allauth.account',

    # Default apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

# Set AUTH_USER_MODEL as my own user model that uses the email address as the username 
AUTH_USER_MODEL = 'trinalysis_app.MyUser'


# allauth config params
SITE_ID = 1
LOGIN_REDIRECT_URL = '/'
ACCOUNT_USER_MODEL_USERNAME_FIELD = None
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'

Where did I go wrong?

like image 805
Ben Avatar asked Mar 03 '16 20:03

Ben


3 Answers

You need to add allauth.socialaccount to INSTALLED_APPS.

More on this can be found in the settings documentation

like image 186
karthikr Avatar answered Oct 15 '22 16:10

karthikr


You need to add allauth.socialaccount to INSTALLED_APPS or override login.html template and not include 'socialaccount' tag.

like image 2
jmrivas Avatar answered Oct 15 '22 16:10

jmrivas


For anyone with same error in future.

There will be some conditions if you see such error

'socialaccount' is not a registered tag library. Must be one of:
 accounts
 account_tags
 ....
  1. if you have imported {% load socialaccount %} in template. eg. login.html and not included allauth.socialaccounts in INSTALLED_APPS
  2. or you didn't makemigrations or did not migrate . you have done makemigrations and migrated

in my case i removed all all.auth from settings.py but forget to remove {% load socialaccount %} from template file.. but solved in time ..

like image 2
Jahanzeb Nawaz Avatar answered Oct 15 '22 17:10

Jahanzeb Nawaz