Django Admin Cookbook: How to do things with Django Admin by Shabda Raaj
Author:Shabda Raaj [Raaj, Shabda]
Language: eng
Format: epub
Publisher: Agiliq Info Solutions India Pvt Ltd
Published: 2018-07-29T23:00:00+00:00
1. How to restrict Django admin to specific users?
Django admin allows access to users marked as is_staff=True. To disable a user from being able to access the admin, you should set is_staff=False.
This holds true even if the user is a superuser. is_superuser=True. If a non-staff tries to access the admin, they see a message like this.
2. How to restrict access to parts of Django admin?
You can enable and restrict access to specific parts of Django admin using the permission system. When a model is added, by default, Django creates three permissions. add, change and delete
Admin uses these permissions to decide access for users. For a user with is_superuser=False, and no permissions, the admin looks like this
If you add a permission user.user_permissions.add(Permission.objects.get(codename="add_hero")), the admin starts looking like this
You can add more complex logic to restrict access by changing these methods:
def has_add_permission(self, request): ... def has_change_permission(self, request, obj=None): ... def has_delete_permission(self, request, obj=None): ... def has_module_permission(self, request): ...
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12569)
Hello! Python by Anthony Briggs(9914)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9795)
The Mikado Method by Ola Ellnestam Daniel Brolund(9777)
Dependency Injection in .NET by Mark Seemann(9337)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8296)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7062)
Microservices with Go by Alexander Shuiskov(6824)
Practical Design Patterns for Java Developers by Miroslav Wengner(6741)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6684)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Angular Projects - Third Edition by Aristeidis Bampakos(6088)
The Art of Crafting User Stories by The Art of Crafting User Stories(5615)
NetSuite for Consultants - Second Edition by Peter Ries(5554)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5356)
Kotlin in Action by Dmitry Jemerov(5062)
