GithubHelp home page GithubHelp logo

ojii / django-rulez Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chrisglass/django-rulez

1.0 3.0 0.0 120 KB

A lean and mean object-level rules system for the Django framework

License: BSD 3-Clause "New" or "Revised" License

django-rulez's Introduction

django-rulez

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)

django-rulez's People

Contributors

jjmaestro avatar maraujop avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.