9๐
โ
As pointed out by Daniel above, i had this stupid snippet in the settings file, which was causing the problem,
#REST_FRAMEWORK = {
# '''Use hyperlinked styles by default'''
# '''only used if serializer_class attribute is not set on a view'''
# 'DEFAULT_MODEL_SERIALIZER_CLASS':
# 'rest_framkework.serializers.HyperLinkedModelSerializer',
# 'DEFAULT_PERMISSION_CLASSES':
# 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
# }
Commmented this and it worked.
๐คSirius
109๐
Just to let others know, I kept getting this same error and found that I forgot to include a comma in my REST_FRAMEWORK
. I had this:
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated'
),
instead of this:
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
The comma defines this as a one-element tuple
๐คdbryant4
- [Django]-Django [Errno 13] Permission denied: '/var/www/media/animals/user_uploads'
- [Django]-Getting the SQL from a Django QuerySet
- [Django]-Postgresql DROP TABLE doesn't work
18๐
In my case the typo was in views.py
. Instead of โฆ
permission_classes = (permissions.IsAuthenticated,)
โฆ I had โฆ
permission_classes = (permissions.IsAuthenticated)
๐คChris
- [Django]-Generate a Unique String in Python/Django
- [Django]-Order Django Query Results by Foreign Key
- [Django]-Upload image available at public URL to S3 using boto
6๐
I had the same error when I used custom permissions, because of a โtypoโ
I had:
@permission_classes(EventByFacilityPermissions)
class EventByFacilityViewSet(viewsets.ModelViewSet):
instead of:
@permission_classes((EventByFacilityPermissions,))
class EventByFacilityViewSet(viewsets.ModelViewSet):
๐คMarco Silva
- [Django]-What is the easiest way to clear a database from the CLI with manage.py in Django?
- [Django]-How to get the label of a choice in a Django forms ChoiceField?
- [Django]-Using Django auth UserAdmin for a custom user model
5๐
Pass the authentication class inside your class instead of in your settings.py if you need authentication just in some classes, and do like this:
authentication_classes = [TokenAuthentication, ]
instead of like this:
authentication_classes = TokenAuthentication
๐คGregory
- [Django]-Rounding off decimals in Django
- [Django]-How do I use CreateView with a ModelForm
- [Django]-When to use Django get_absolute_url() method?
Source:stackexchange.com