Django permissions framework vs DRF permissions

2019-05-18 Thread Rounak Jain
Newbie here. I want to create hierarchical permissions in Django, very 
similar to one described 
here: https://stackoverflow.com/questions/49300215/django-hierarchy-permissions

I have read about Django permissions framework and 
https://github.com/vintasoftware/django-role-permissions

I don't understand where DRF permissions fit it? Should DRF permissions be 
used in addition to or instead of Django permissions?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b1e37c07-e223-4244-bb4a-09e3cd0f7737%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Write urls without regex in DRF

2019-05-22 Thread Rounak Jain
I am using DRF Viewsets to auto-generate URLs for different views. Is it
possible to write the code below without using regex?
Thanks

from .views import TaskViewSet
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
router.register(r'', TaskViewSet, basename='task')
urlpatterns = router.urls

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANNuxWNoPGePbAcxnWqzMgeioYXKXwD1Yn-H_2-FN774MdsbbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Show different views based on user

2019-05-22 Thread Rounak Jain
I am new to Django. Below code returns objects created by the logged in
user. If the user's role property has value 'super', then I want all the
objects to be shown. If the user's role property is 'inter', then I want to
show all objects except objects created by 'super'. Where is the right
place to do this conditional querying?
Thanks

#views.py

class TaskViewSet(ModelViewSet):
serializer_class = TaskSerializer
def get_queryset(self):
return Task.objects.all().filter(created_by=self.request.user)
def perform_create(self, serializer):
serializer.save(created_by=self.request.user)

#serializers.py

class TaskSerializer(ModelSerializer):

class Meta:
model = Task
fields = ('id', 'name', 'status', 'created_by')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANNuxWPeGAgGEikRkoYgdp%3Dse9W0MBVxsLwac1W_BJw0%3DtmGOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Write urls without regex in DRF

2019-05-22 Thread Rounak Jain
Thanks for the reply. I understand how to use them in urls.py when creating
normal routes but here in case of drf, it would help if you could show me
how to do it

On Wed, May 22, 2019 at 10:11 PM Onasanya Tunde 
wrote:

> Use Django2.X
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/67314c66-6d50-4390-80de-67d8151fe9a0%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANNuxWNacKstGmD2jwy3r3NYKf_R4BtoqMTBiBoTEaDAL5eb-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Write urls without regex in DRF

2019-05-22 Thread Rounak Jain

I cannot see any reply 
On Thursday, May 23, 2019 at 7:56:54 AM UTC+5:30, Kevin Jay wrote:
>
> kevin@kjay,net
>
> On Wed, May 22, 2019 at 10:19 AM Rounak Jain  > wrote:
>
>>
>> I am using DRF Viewsets to auto-generate URLs for different views. Is it 
>> possible to write the code below without using regex?
>> Thanks
>>
>> from .views import TaskViewSet
>> from rest_framework.routers import DefaultRouter
>>
>> router = DefaultRouter()
>> router.register(r'', TaskViewSet, basename='task')
>> urlpatterns = router.urls
>>
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CANNuxWNoPGePbAcxnWqzMgeioYXKXwD1Yn-H_2-FN774MdsbbQ%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/CANNuxWNoPGePbAcxnWqzMgeioYXKXwD1Yn-H_2-FN774MdsbbQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6a1efd52-570c-445f-b4d8-61cd13ae67d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.