How to give permission to admin and author for view specific page in django?

right now my this code only allow it's original author to view an specific page. If author id and user id not same then it will return 404 page. here is my code:

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

how to add permission for admin above code. so admin also can view the page.



Read more here: https://stackoverflow.com/questions/67921047/how-to-give-permission-to-admin-and-author-for-view-specific-page-in-django

Content Attribution

This content was originally published by boyenec at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: