How it works...

The default user administration list looks similar to the following screenshot:

The default group administration list looks similar to the following screenshot:

In this recipe, we created two models:

  • The Role model, which is a proxy for the Group model from the django.contrib.auth app. The Role model was created to rename the verbose name of Group to Role.
  • The User model, which extends the same abstract AbstractUser class as the User model from django.contrib.authThe User model was created to replace the primary key with UUIDField and to allow us to log in via email and password instead of username and password.

The admin classes, MyUserAdmin and MyRoleAdmin, extend the contributed UserAdmin and GroupAdmin classes and overwrite some of the properties. Then, we unregistered the existing administration classes for the User and Group models and registered the new, modified ones.

The following screenshot shows what the user administration looks like:

The modified user administration settings show more fields than the default settings in the list view, additional filters and ordering options, and Submit buttons at the top of the editing form.

In the change list of the new group administration settings, we will display those users who have been assigned to specific groups. In the browser, this will look similar to the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.36.141