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.
Asked
Active
Viewed 28 times
1 Answers
0
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

intelis
- 7,829
- 14
- 58
- 102