10. Logging Users In and Out

Django lets you keep track of who’s logged in on your site, and you can track users from page to page, as you’ll see in this chapter. Here, we’re going to create an application that lets users log in, greets them by name when they do, and lets them log out.

The application is named login, and it will consist of three pages: a main page that greets users by name if they’re logged in or, if they’re not logged in, invites them to log in; a login page with text fields for username and password; and a logout page (which is actually not a page at all—it’s just a view that logs users out and returns them to the main page).

So when a user opens the application, the user will be invited to log in. When the user logs in, the ...

Get Django: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.