Package: django-tabular-permissions
Display django permissions in a user friendly, translatable and customizable widget .RTL and localizedWith Custom permission behaviourVersion2.9.1 (June 7 2022)Features:Permissions and their relevant app and models names are displayed in the active language.Permissions are displayed in a table that contain the default model permissionsplusany custom permissions.Supports view permission (started with Django 2).Customize which apps, models to show in the permissions table. You can also set a exclude function for high-end customization.RTL ready, Bootstrap ready.Easy customize-able look.Python 2.7, 3.6, 3.7, 3.8, 3.9 , 3.10. Django 1.11, 2.1, 2.2, 3.0, 3.1, 3.2 , 4.0, 4.1, 4.2DefaultFilteredSelectMultiplewidget will appear only if you have custom permissions that are not model related (ie directly created by code or hand)InstallationYou can installdjango-tabular-permissionsvia Pypi:pip install django-tabular-permissionsand add “tabular_permissions” to your INSTALLED_APPS setting (at any place afterdjango.contrib.auth)INSTALLED_APPS = [
    'django.contrib.auth',
     ....
    'tabular_permissions',
]Finally, execute:python manage.py collectstaticthen navigate to User and/or Group change form to seetabular_permissionsin action.Configuration:Tabular permissions possible configurations and their default:TABULAR_PERMISSIONS_CONFIG = {
    'template': 'tabular_permissions/admin/tabular_permissions.html',
    'exclude': {
        'override': False,
        'apps': [],
        'models': [],
        'function':'tabular_permissions.helpers.dummy_permissions_exclude'
    },
    'auto_implement': True,
    'use_for_concrete': False,
    'custom_permission_translation': 'tabular_permissions.helpers.custom_permissions_translator',
    'apps_customization_func': 'tabular_permissions.helpers.apps_customization_func',
    'custom_permissions_customization_func': 'tabular_permissions.helpers.custom_permissions_customization_func',
}templatethe template which contains the permissions table, you can always customize this template by extending or overriding.
Notice that there is astyleblock which you can override to easily edit the css.excludeControl which apps, models to show in the permissions table.By defaulttabular_permissionsexcludesessions,contenttypesandadminapps from showing their models in the permissions table. If you want to show them you can switchoverridetoFalse.apps&modelslists would contain the names of the apps and models you wish to exclude.functionis a dotted path of a custom function which receive the model as a parameter to decide either to exclude it or not, default to a dummy function that always return False (ie do not exclude)auto_implementBy default, just by includingtabular_permissionsin your installed_apps, thedjango.contrib.admin.UserAdmin(andGroupAdmin) are “patched” to include the tabular_permissions widget.
If you have a custom UserAdmin, then set this option to False and make sure you either:Inherit fromtabular_permissions.admin.TabularPermissionsUserAdminandtabular_permissions.admin.TabularPermissionsGroupAdminfor User & Group ModelAdmin.Or for a more direct and compact way, inherit your ModelAdmin fromtabular_permissions.admin.UserTabularPermissionsMixinandtabular_permissions.admin.GroupTabularPermissionsMixin(comes before admin.ModelAdmin in the mro),Set the user_permissions widget totabular_permissions.widgets.TabularPermissionsWidgetand remember to send a 3rd argument ‘permissions’ for Group Model Admin.
Seetabular_permissions.adminfor information.use_for_concreteDefault: False (new in version 2.8)There was an inconsistency with proxy models permissions (Django ticket11154) which got fixed in Django 2.1
In case you’re on an django <2.1 and you have proxy models and you created their permissions by hand (via thisgistmaybe), then turn off this option in order to correctly assign your newly created permissions.
For django > 2.1, leave it as is you should be good.custom_permission_translationA dotted path function to translate the custom permission.
This function gets passed the permissionscodename,verbose_nameand its relevantcontent_type_id.
The function will try to translate the permission verbose_name.apps_customization_funcA dotted path function to control the whole permissions objects passed to the widget.
Sometimes you use custom menu where apps and models are ordered in a more “user friendly” manner and not necessarily
in the “actual programmatic” apps & models order.
You can use this option to get a hold of the whole ordered dict and shuffle its content around moving
models from one app to the other and do all kind of crazy stuff to get just the right table of permissions.custom_permissions_customization_funcA dotted path function to control the “extra” permissions which will be displayed on the default django widget.
Suppose a model is removed, or an app is commented out ofINSTALLED_APPS; its permissions are still in the
permissions table, and it will be picked up.
Use this function to manipulate and order those permissions and return them .
The permissions are passed a list of tuples , like this[(perm_id, perm_name), (perm_id, perm_name),...]JavaScript:Located at ‘static/tabular_permissions/tabular_permissions.js’, it have 2 responsibilities:Upon form submit, the checked permissions in the table are dynamically appended to the form default permission input so the backend can carry on its functionality normally and correctly.Add handlers for column and rowselect-allcheckboxes.Compatibility:Current version support from Python 2.7 and up to Python 3.10, and Django from 1.11 to 4.1
For Django < 1.11, use django-tabular-permissions 1.0.9.Demo:To run the demo project in the repo on your local you needClone the repo;Create a virtualenvpip install django-tabular-permissionspython manage.py migratepython manage.py runserverTestsTo run the tests, you need to install the test requirements:cd tests
pip install -r requirements.txtThen run:python runtests.pyWith Coveragecoverage run runtests.py
coverage htmlCross ReferenceIf you like this package, chances are you may like those packages too!Django Slick ReportingPowerful and Efficient reporting engine with Charting capabilities.Django Ra ERP FrameworkA framework to build business solutions with ease.