User and Group Management

Learn about user and group management in the Django admin application.

Duplicating admin access

If you want to create different admins and provide them with access, you will have to form a new admin class

class MySecondAccessAdminSite(AdminSite):
	site_header = "Second Admin site"
	site_title = "Second Admin Portal"
	index_title = "Welcome to your second dashboard"

second_admin_site = MySecondAccessAdminSite()
second_admin_site.register(Author, AuthorAdmin)

Then, you will need to add a new url to for your new admin (the second-admin in this example):

from sample_app.admin import site, second_admin_site = site

urlpatterns = [
	path('second-admin/', second_admin_site.urls),

Do not forget to register the models you want to display in this new admin.

If you append /second-admin/ at the end of your web app URL instead of the /admin/ you will see your second admin page and it will show only the models you have registered with this new admin page.

Managing admin permissions for users and groups

You can create a new user by clicking on the add button next to the Users under the AUTHENTICATION AND AUTHORIZATION tab. Remember that you will need to register your User and Group models with the new admin site for AUTHENTICATION AND AUTHORIZATION in order for them to appear on the admin page:

second_admin_site.register(User, UserAdmin)

To let users access the Django admin while creating their accounts, you will need to set the is_staff property to true.

Get hands-on with 1200+ tech skills courses.