Appying Denning security Model for django admin site

39 views Asked by At

I wanted to know the procedure of implementing the denning security model for the admin page in django web framework. For this i will have to create subjects and objects. Subjects are users and admin. Objects are appmodels and log entries. This model should replace the existing permissions setup for a user. How can i program it easily.

1

There are 1 answers

0
intelis On

If I understand your question correctly, in order to allow or deny access to specific parts of admin I've been using something like this in my project.

#admin.py
    class MyForm(forms.ModelForm):
        class Meta:
            model = MyModel
            fields = '__all__'

        def __init__(self, *args, **kwargs):
            super(MyForm, self).__init__(*args, **kwargs)

            if self.current_user.is_superuser:
                # Do something

            if not self.current_user.is_superuser:
                # Do something else