Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

Stay at model level #77

Description

@LucasBerbesson

Hello,
I love this package, it's awesome thank you.
Is there a way to use the permission_required decorator on a ListView (or any CBV with a get_queryset method) on a Model level and thus checking the has_perm only once.

Right now I'm using the django.contrib.auth.mixins.PermissionRequiredMixin, but I love the permission_required decorator.

Basically I would love to do something like

from permission.decorators import permission_required

@permission_required('blog.view_post',stay_at_model_level=True)
class PostList(ListView):
    model = Post

Instead of doing :

from django.contrib.auth.mixins import PermissionRequiredMixin

class PostList(PermissionRequiredMixin, ListView):
    model = Post
    permission_required = 'blog.view_post'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions