These are my notes for setting up Django-Allauth to do the following:
- All users will use their email address as their username
- Users will have the option of manually entering their email and password or using a social account for both login and signup.
- The web forms will be based on Bootstrap
Here are the settings options to make that happen:
ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_EMAIL_VERIFICATION = 'mandatory' SOCIALACCOUNT_EMAIL_VERIFICATION = 'none'
Login is pretty straight forward. All-Auth makes it easy to add buttons to login with social accounts (e.g. “Login using Google”, etc…). What is less obvious is how to signup using social authentication. If you use the settings above, Allauth social authentication login will create a new user if that user’s email is not already in the system. Signup is not necessary. For me, that was the missing piece.
Django-Allauth is extendable is just about every dimension you can imagine. Maybe that is part of what makes it difficult to use; there are some many options, it’s difficult to decide which ones you need/want. One thing I wanted to do was replace the Allauth templates with one of my own. Django has built in functionality for over-riding templates. Allauth uses that. To create your own login and signup templates, just add an folder called “account” to your main templates folder. In that folder, put “login.html” and “signup.html”. You may also want to add “base.html”.