Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
142 views
in Python by (178k points)
How can I restrict access to certain models in Django Admin?

Please log in or register to answer this question.

1 Answer

0 votes
by (178k points)

Django Admin provides a permissions system that allows you to control access to models and their actions. You can assign different permissions to different user groups or individual users.

Example code:

# admin.py
from django.contrib import admin
from .models import MyModel

class MyModelAdmin(admin.ModelAdmin):
    # ...

# Restrict access to MyModel for non-superusers
def has_module_permission(self, request):
    if request.user.is_superuser:
        return True
    return False

admin.site.register(MyModel, MyModelAdmin)
 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...