skip to Main Content

I am building a django ERP project, in which there will be multiple user’s, admin,user, manager etc. Each of this user has separate user credentials to login. Each user have separate dashboard. I’m using local database for login function.

I want to give access to every user from admin dashboard, like view, edit,and delete, allow them to download csv file. I am trying to make privilege page for each user in admin dashboard. When a radio button or check box turn on, that respective user had to access the privilege.

2

Answers


  1. You can use django’s built-in permission system and also you can create your own custom permissions in django. If you need more clarity regarding this topics please add your sample code, i can help with that or otherwise you can refer the below link:

    https://docs.djangoproject.com/en/5.0/topics/auth/default/#permissions-and-authorization

    Login or Signup to reply.
  2. I have been using this in my project to manage different types of users

    Creating a group

    group_name = 'manager'
    group_obj = Group.objects.filter(name=group_name)
    if not group_obj:
        Group.objects.create(name=group_name)
    

    Manage user access to the view

    @api_view(['GET'])
    def my_view(request):
        if request.user.is_authenticated and request.user.groups.filter(name__in=['manager']).exists():
            print('Access granted')
        else:
            print('Access denied')
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search