AllAuth
is one of the best and widely used Python Django libraries used for authentication. It supports username and password-based authentications as well as using social media accounts.
If you are started using it, you might have realized that default Django forms are simple HTML and without styling.
You also might want to apply your project base template so that it will look inclined to your project design.
The best option is to override the default allauth
form templates and customize them based on our requirements.
What you can achieve by overriding allauth
templates?
Instead of writing your own templates, just copy-paste the allauth
templates in your project directory templates and edit them as you want.
allauth
templates.\<virtual-environment>\lib\python3.6\site-packages\allauth\templates\
\<project-name>\<app-name>\templates\
Now you can edit newly copied templates. DOn’t touch the original one. There are mainly two template sets.
account
template forms for username-password-based authentication Here are the HTML templates.
account_inactive.html email_confirm.html logout.html password_change.html password_reset_done.html password_reset_from_key_done.html signup.html verified_email_required.html base.html email.html login.html password_reset.html password_reset_from_key.html password_set.html signup_closed.html verification_sent.html
socialaccount
template forms for social-media-based authentication.Here are the HTML templates.
authentication_error.html base.html connections.html login.html login_cancelled.html signup.html
These template names are self-explanatory. Be mindful while editing these templates.
Note: There are many alternatives to implement social media Django authentication like social-auth-app-django
. But, my choice goes with AllAuth. There are many reasons. This is out of scope now.
Any further questions on how to override Django-AllAuth template? Let me know in the comment. I keep sharing more Django tutorials so stay tuned and best wishes!
Thanks! Worked for me.
I’m glad it worked for you. Happy coding!
still default templates are showing
Not sure. Please follow all the steps mentioned in this tutorial. It should solve your problem.