← Back to Django Course | Chapter 8: Django Admin | Lesson 8 of 8

Admin Permissions

Admin permissions decide which staff users are allowed to view, add, change, or delete each type of record.
Syntax
markup
# Default permissions per model: add, change, delete, view
user.has_perm('app_name.add_modelname')

from django.contrib.auth.models import Permission
user.user_permissions.add(Permission.objects.get(codename='change_modelname'))

The Four Default Permissions

For every model Django registers, it automatically creates add, change, delete, and view permissions. A staff user needs the relevant one to perform that action in the admin.

Example: The Four Default Permissions

Lists the four auto-created permissions for a Book model.

bash
python manage.py shell
>>> from django.contrib.auth.models import Permission
>>> Permission.objects.filter(content_type__model='book')
<QuerySet [<Permission: core | book | Can add book>, <Permission: core | book | Can change book>, ...]>

⚠️ Run this in your own terminal or Node.js environment.

Assigning Permissions Directly to a User

A staff user (is_staff=True) with no permissions sees an empty admin. Permissions must be granted explicitly, either individually or through a group.

Example: Assigning Permissions Directly to a User

Grants the editor user permission to change Book records in the admin.

bash
python manage.py shell
>>> from django.contrib.auth.models import User, Permission
>>> user = User.objects.get(username='editor')
>>> perm = Permission.objects.get(codename='change_book')
>>> user.user_permissions.add(perm)

⚠️ Run this in your own terminal or Node.js environment.

Using Groups for Bulk Permissions

Instead of assigning permissions one user at a time, create a Group with the right permissions and add users to it -- much easier to manage as your team grows.

Warning: is_superuser overrides all of this: a superuser can do everything regardless of assigned permissions or group membership.

Example: Using Groups for Bulk Permissions

Creates an Editors group with the change_book permission and adds the user to it.

bash
python manage.py shell
>>> from django.contrib.auth.models import Group
>>> editors = Group.objects.create(name='Editors')
>>> editors.permissions.add(perm)
>>> user.groups.add(editors)

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Giving a user is_staff=True without any specific permissions, then being confused why they see an empty admin with nothing to manage.
  2. Confusing is_staff (can log in to /admin/) with is_superuser (bypasses all permission checks).
  3. Forgetting that permissions can be granted individually or in bulk through Groups, not just per-user.
Chapter Summary
  • Every model gets four automatic permissions: add, change, delete, and view.
  • is_staff allows admin login; individual permissions decide what a staff user can actually do there.
  • Groups bundle permissions together so they can be assigned to many users at once.
  • is_superuser bypasses all permission checks entirely.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.