/django-admin-view-permission

Reusable application which provides a view permission for the existing models.

Primary LanguagePythonBSD 2-Clause "Simplified" LicenseBSD-2-Clause

Admin View Permission

Build Status Coverage Status Code Climate

Reusable application which provides a view permission for the existing models.

Requirements

  • Django

Support

  • Django: 1.8, 1.9, 1.10
  • Python: 2.7, 3.4, 3.5

Documentation

For a full documentation you can visit: http://django-admin-view-permission.readthedocs.org/

Setup

  • pip install django-admin-view-permission

and then add admin_view_permission at the INSTALLED_APPS like this:

INSTALLED_APPS = [
    'admin_view_permission',
    'django.contrib.admin',
    ...
]

and finally run python manage.py migrate.

Configuration

This app provides a setting:

ADMIN_VIEW_PERMISSION_MODELS = [
    'auth.User',
    ...
]

in which you can provide which models you want to be added the view permission. If you don't specify this setting then the view permission will be applied to all the models.

You can also use another setting in which you can provide models which you want to be excluded from the view permission. The view permission will be applied to all the models except those listed in this list:

ADMIN_VIEW_PERMISSION_EXCLUDE_MODELS = [
    'auth.User',
    ...
]
warning:You can't use both settings at the same time.

Uninstall

  1. Remove the admin_view_permission from your INSTALLED_APPS setting

  2. Delete the view permissions from the database:

    from django.contrib.auth.models import Permission
    permissions = Permission.objects.filter(codename__startswith='view')
    permissions.delete()
    

    It will be helpful to check if the queryset contains only the view permissions and not anything else (for example: custom permission added)