21.5 Disabling Accounts

Before we create new user accounts, we first see how to disable user accounts.

When building a website, the ideal in usability is to first disable a user account and then delete the account some time later. Disabling an account means ensuring the user may no longer log in. Out of the box, Django immediately supports both disabling and deleting user accounts. Deleting an account is so straightforward and simple (particularly in our case), that we look only at disabling an account.

Unlike what it does for password management, Django does not supply any views for us to rely on when it comes to disabling a user account, so we must build our own view (Example 21.24). The idea is to build a page that disables the account of ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.