0% found this document useful (0 votes)
8 views3 pages

Django User Management 13 Marks

The document outlines how to manage users in Django's admin interface, detailing the creation of normal users and superusers, as well as user permissions and group management. Users can be created programmatically or through the admin interface, and permissions can be assigned or modified. Groups facilitate the management of users with similar roles, allowing for efficient permission assignment across multiple users.

Uploaded by

tamilgunner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Django User Management 13 Marks

The document outlines how to manage users in Django's admin interface, detailing the creation of normal users and superusers, as well as user permissions and group management. Users can be created programmatically or through the admin interface, and permissions can be assigned or modified. Groups facilitate the management of users with similar roles, allowing for efficient permission assignment across multiple users.

Uploaded by

tamilgunner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Managing Users in Django Admin - 13 Mark Answer

In Django, users are people who interact with the web application. The Django admin interface

allows managing users efficiently.

There are two main types of users: normal users and superusers (admins). The admin interface

helps with creating, editing, grouping,

and managing user permissions.

A) Creating Users

Users can be created in two ways:

1. Programmatically using code:

from django.contrib.auth.models import User

user = User.objects.create_user('XYZ', '[email protected]')

user.last_name = 'ABC'

user.save()

2. Through the Django admin interface:

- Navigate to the Users section.

- Click the green "+" button to add a new user.

- Set a username and password.

Creating a Superuser:

Superusers have full access to the admin panel.


To create one, use the terminal:

python manage.py createsuperuser

You'll be asked to enter a username, email, and password.

B) User Permissions and Status

- By default, new users have no permissions.

- Admins can set user roles using the admin panel.

- Permissions can be changed using:

user.user_permissions.set([...])

user.user_permissions.add(permission1, permission2)

user.user_permissions.remove(permission)

- Checkboxes like Active, Staff, and Superuser define user privileges.

C) Managing Groups

Groups help manage users with similar roles efficiently.

1. Creating Groups:

- Go to the Groups section in the admin.

- Click Add, set the group name and permissions, then save.

2. Assigning Users to Groups:


- Go to the user's profile in the admin.

- Use the dropdown to add them to one or more groups.

3. Group Permissions:

- Permissions given to a group apply to all its users.

- Example: An "Editor" group can be given permission to modify content. All users in this group get

the same access.

Conclusion

Django's admin interface provides a powerful way to manage users and permissions. Superusers

can create, delete, and edit users, assign roles,

and manage groups to control access and functionality across the web application.

You might also like