A lean and mean object-level rules system for the Django framework
Project description
django-rulez is a fork of django-rules, since some of the goals django-rules set themselves didn’t match our current project goals.You can refer to their github project page for more information about this cool project: https://github.com/maraujop/django-rules Kudos for the good work guys!
Generally, it is a per-object authorization backend, that stores the rules themselves as methods on model.
Installation
From source
To install django-rulez from source:
git clone https://github.com/cglass/django-rulez/ django-rulez cd django-rulez python setup.py install
From Pypi
Simply install django-rulez like you would install any other pypi package:
pip install django-rulez
Configuration
Add it to the list of INSTALLED_APPS in your settings.py
Add the django-rulez authorization backend to the list of AUTHENTICATION_BACKENDS in settings.py:
AUTHENTICATION_BACKENDS = { 'django.contrib.auth.backends.ModelBackend', # Django's default auth backend 'django_rules.backends.ObjectPermissionBackend', }
Example
The following example should get you started:
# models.py from rulez import registry class myModel(models.Model) def can_edit(self, user_obj): ''' Not a very useful rule, but it's an example ''' if user_obj.username == 'chris': return True return False registry.register('can_edit', myModel)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-rulez-0.2.0.tar.gz
.
File metadata
- Download URL: django-rulez-0.2.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2e7c39bc8aca4a444f5da711b81b11e1bef37ace2a0242beff6130c9e8c1ee6 |
|
MD5 | f5be7008d189fb05ff207049b81a1acb |
|
BLAKE2b-256 | 6eff03f22e2fc1be30fd276e3e4c0b2e4cce11b9862bb754a2d4b0447d1542b6 |