"detail": "Authentication credentials were not provided." when I want to signup user

485 Views Asked by At

when I want to post data and create a new teacher it gives me this error and I don't know what to do please help me

this is my models.py enter image description here

this is my views.py enter image description here

this is my serializer.py enter image description here

1

There are 1 best solutions below

0
Gaëtan GR On BEST ANSWER

You need to edit your settings.py and add this :

  REST_FRAMEWORK = {
   'DEFAULT_AUTHENTICATION_CLASSES': (
       'rest_framework.authentication.TokenAuthentication',
   ),
   'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAdminUser'
   ),
}

But have look for better insight https://www.django-rest-framework.org/api-guide/settings/