How to automatically log in users in with Django

Django does not automatically log in users after signing in, but achieving this functionality only takes a few extra lines of code.

Notes

Django contrib auth provides two functions: authenticate and login. We can call these methods to log a user in without displaying a login form.

The Django source code is a good place to find out more about the authenticate and login methods:

Full-stack developer and Django enthusiast. When I can’t find Django tutorials, I write them. https://twitter.com/alcampk