Skip to main content

Make django router with role permission

Project description

django-role-router is a simply, definition designed router with multi-roles.

You can install it with pip. >pip install django-role-router

To use it, make sure you have installed django-role-router already.

  1. Insert middleware jhvar.django.urls.middleware.JvRoleMiddleware after SessionMiddleware.

  2. You can define app role permission like “permitted_roles = [‘admin’]” in urls.py global section.

  3. You can define path role permission like “jv_path(‘admin’, views.my_admin, name=’my_admin’, roles=[‘admin’])” in urlpatterns list. Path role has more priority than app role.

  4. We have supported regex format with “jv_re_path” function, just like “jv_path”. It can also work with rest_framework router.

  5. You can define logger ‘jhvar.django.logger’ in urls.py logger section, to print debug info.

Now, you have role permission verifier, you should add your role granty in somewhere.

It just like “grant_roles(request, ‘admin’)” or “grant_roles(request, (‘admin’, ‘super’))” or “grant_roles(request, [‘admin’, ‘super’])”.

Join it, have fun!

Visit https://github.com/jhvar/django-utils for more detail.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-role-router-0.2.1.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

django_role_router-0.2.1-py3-none-any.whl (17.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page