Welcome to Django Admin View Permission’s documentation!¶
Contents:
Installation¶
Getting the code¶
The recommended way to install the Admin View Permission
is via pip:
$ pip install django-admin-view-permission
To test an upcoming release, you can install the in-development version instead with the following command:
$ pip install -e git+https://github.com/django-admin-view-permission/django-admin-view-permission.git#egg=django-admin-view-permission
Requirements¶
- Django
Support¶
- Django: 1.8, 1.9, 1.10, 1.11, 2.0
- Python: 2.7, 3.4, 3.5, 3.6
Setup¶
Make sure that 'django.contrib.admin'
is set up properly and add
'admin_view_permission'
to your INSTALLED_APPS
setting:
INSTALLED_APPS = [
'admin_view_permission',
# ...
'django.contrib.admin',
# ...
]
Finally, run python manage.py migrate
to create the view permissions.
In case of a customized AdminSite in order to apply the view permission, you
should inherit from the `AdminViewPermissionAdminSite`
class:
from admin_view_permission.admin import AdminViewPermissionAdminSite
class MyAdminSite(AdminViewPermissionAdminSite):
...
Configuration¶
The admin view permission provides one setting that you can add in your project’s settings module to customize its behavior.
Management commands¶
The admin view permission provides one management command which fixes the permissions on the proxy models.
fix_proxy_permissions¶
This command will create the appropriate entries on the ContentType and Permission models. Then it will delete the permissions, which are created from django migrate command and are associated with the parent model. More information you can find here.
Example¶
python manage.py fix_proxy_permissions
Uninstall¶
To remove the application completely firstly remove the admin_view_permission
from your INSTALLED_APPS
setting and then open a debug shell and execute
the following commands in order to remove these extra permissions from the
database:
from django.contrib.auth.models import Permission
permissions = Permission.objects.filter(codename__startswith='view')
permissions.delete()
Note
Before delete the permission would be helpful to check if the permissions queryset contains only the view permissions and not anything else.
\ Sort by:\ best rated\ newest\ oldest\
\\
Add a comment\ (markup):
\``code``
, \ code blocks:::
and an indented block after blank line