Questions tagged [django-permissions]

django-permissions is a pluggable django app that provides per-object permissions for Django based on roles

django-permissions is a pluggable django app that provides per-object permissions for Django based on roles.

431 questions
2
votes
1 answer

Django Authorization Checking in URL having wild card pattern

I am trying to implement permission checking mechanism in URLs for a request using wildcard techniques, rather than implement permission checking on each views. Currently What I have is. urlpatterns = [ path('admin/', include('admin_urls.py')), …
2
votes
0 answers

How to enforce user permissions using user Groups in Django Class Based Views

In my Django app, I have created Groups and assigned (selectively) Permissions the Groups. And later assigned the Groups to the Users. These steps were carried out in the app's admin. Now I am trying to restrict certain views to the users (using…
2
votes
1 answer

Restricting view by model permissions fails in django

Very basically I have a model member and want to restrict searching members to allowed users. I use the following in the corresponding view if request.user.has_perm('view_member'): context['user_list'] = get_user(q) Sadly this does not work…
Moanos
  • 314
  • 3
  • 11
2
votes
3 answers

How to prevent users from seeing all content in Django?

I have a website and I want to prevent visitors to seeing content unless they have permission. How can I restrict them?
Darwin
  • 1,695
  • 1
  • 19
  • 29
2
votes
0 answers

Update Task APIView' object has no attribute 'action'

I'm totally new in django and rest. I wanna write a program that only lets the owner update or delete his tasks. When I try to use it, it doesn't prohibit me to update or delete (others tasks) and when I press the update or delete button it returns…
2
votes
1 answer

DjangoModelPermissions is not working for view level permission in my API application

I have created an API and I am trying to provide permissions to the views in my API app. I have assigned users to groups with permissions in my admin portal and then I am using DjangoModelPermissions in my views so that the permissions behave…
2
votes
1 answer

How to implement dynamic creation of permission groups with different set of endpoints Django Rest Framework

In my project I have lot of endpoint views (APIViews, ViewSets). For all of them now I set permissions, some of them are default (e.g. AllowAny) and some are custom created: permission_classes = (IsUserHaveSomePermission,) Now I want to implement…
2
votes
1 answer

How to approve all installed apps permission programmatically in Django

settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', …
Tareq Monwer
  • 185
  • 1
  • 13
2
votes
1 answer

Rename django custom permissions

I'm working with django 2.0 app and going to update django version to 3.0. But in my project there are few custom permissions named like view_modelname. class MyConcreteModel(models.Model): model_field_1 = models.CharField(max_length=100,…
2
votes
1 answer

How to combine/mix object level and user level permissions in DRF?

I am currently working on a DRF project where Admin users, Teacher users and Owner users should be able to have access to an objects detail-view. Basically all user types except those who are not the owner of the object or a teacher or an admin…
2
votes
1 answer

How to set permissions for users

I am trying to set permissions for users my django project. What I want to achieve is: User should be able to view/update only his information when logged in An non-logged in user should be able to create a new user My code is as…
2
votes
2 answers

Different Permissions using decorators for each methods inside ModelViewset methods for "list", "create" , "retrieve", "update"

I want to add different permissions for different methods of ModelViewset class using decorator. I tried: class abcd(viewsets.ModelViewSet): @permission_classes(IsAuthenticated,)) def list(self, request, format=None): try: …
2
votes
0 answers

Defining and assigning roles per object in Django

What could be a good way to define roles using django-guardian? I would like to set to a users groups of permissions over an object, and so that permissions can be added to the role and be accesible to all the users associated with a particular…
2
votes
3 answers

Django Admin: Show different models to different users

I have two superusers (user1 and user2) and two models (ModelA and ModelB). In the admin page, I want to show just ModelA to user1, so user1 can only edit ModelA instances but not ModelB instances. Similarly, I want to have user2 able to edit ModelB…
Seves
  • 135
  • 2
  • 12
2
votes
0 answers

Django rest framework redirect if permission denied

I am new in Django-rest-framework. I am learning about authentication and permissions. I am getting stuck at one point. I have created custom permission for selected users. So if some user doesn't have the correct permission for some view class, it…
Amit
  • 861
  • 1
  • 9
  • 18