Hello,

No. You can set this "globally" in settings and then overight as needed in
views (CBV, FBV)
Actually, for secutrity matters, is a best practice to do exactly like this:

First you close you API access in settings, by allowing access to
administrators only, then, on each class or function you overright this.

"
REST_FRAMEWORK = {

    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAdminUser',
    )}
"
Take a look at documentation, there are very good examples there.
https://www.django-rest-framework.org/api-guide/permissions/

Regards,


Em qua, 12 de dez de 2018 às 04:10, Akash utreja <utreja.ak...@gmail.com>
escreveu:

> Hi thanks for reply.
> Is it mandatory to put permission classes in each class? and what about
> functional views?
>
>
> On Tuesday, December 11, 2018 at 4:03:32 AM UTC+5:30, Wandss wrote:
>>
>> Hi, did you add permission_classes in your view or in your settings? If
>> not I believe you sholud do something like:
>> In your .views file:
>>
>> from rest_framework.permissions import IsAuthenticated
>>
>> Then inside your class:
>>
>> Class SomeAPIView(APIView):
>>     permission_classes = (IsAuthenticated,)
>> .... the rest o your class....
>>
>> Regards.
>>
>>
>> Em Seg, 10 de dez de 2018 11:33, Akash utreja <utreja...@gmail.com
>> escreveu:
>>
>>> Hi, I am using built in token authentication of django but I am getting
>>> weird error that some of my request got 200 and some of then got 401
>>> unauthorized when  I run it on server same with localhost. Both request
>>> have same token value I've checked multiple times.Can anyone tell what is
>>> thing i am missing. please help me out here!
>>> My request header is like Authorization: Token <token key>
>>> Here is my settings.py file containing.
>>> REST_FRAMEWORK = {
>>> 'DEFAULT_AUTHENTICATION_CLASSES': (
>>> 'rest_framework.authentication.TokenAuthentication',
>>> )}
>>> Thanks
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django REST framework" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-rest-framework+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-rest-framework+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to