[Answered ]-How to give permission to admin and author for view specific page in django?

1👍

Using your example:

def get_object(self):
    obj = super(BlogListMyAccount,self).get_object()
    if obj.author  != self.request.user and not self.request.user.is_superuser:
       raise PermissionDenied      
    return obj

Usually this is how you check if the user have admin permissions: request.user.is_superuser.

References:

https://www.codegrepper.com/code-examples/python/how+to+check+if+user+instance+is+admin+django+permissions

Leave a comment