Doing just a get request on auth/users/me/ results in this error which says the above. Couldn’t find anything that helps. Can you help me figure out where this error is coming from and how can I fix it. The link to the tutorial I was following is below. Just had setup a new project and installed djoner with jwt. Below is a detailed error message
Djoner link https://djoser.readthedocs.io/en/latest/sample_usage.html
Internal Server Error: /auth/users/me/ Traceback (most recent call last): File "/home/prashant/project/env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/prashant/project/env/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/prashant/project/env/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/prashant/project/env/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/home/prashant/project/env/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view return self.dispatch(request, *args, **kwargs) File "/home/prashant/project/env/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch response = self.handle_exception(exc) File "/home/prashant/project/env/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "/home/prashant/project/env/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception raise exc File "/home/prashant/project/env/lib/python3.8/site-packages/rest_framework/views.py", line 497, in dispatch self.initial(request, *args, **kwargs) File "/home/prashant/project/env/lib/python3.8/site-packages/rest_framework/views.py", line 415, in initial self.check_permissions(request) File "/home/prashant/project/env/lib/python3.8/site-packages/rest_framework/views.py", line 333, in check_permissions self.permission_denied( TypeError: permission_denied() got an unexpected keyword argument 'code' [28/Oct/2020 17:40:20] "GET /auth/users/me/ HTTP/1.1" 500 16964
settings.py
# SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] REST_FRAMEWORK = { # Use Django's standard `django.contrib.auth` permissions, # or allow read-only access for unauthenticated users. 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.authentication.JWTAuthentication', ], 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.AllowAny', ], } INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'djoser', ] # JWT Settings SIMPLE_JWT = { 'AUTH_HEADER_TYPES': ('JWT',), } MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'channels.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'channels.wsgi.application' # Database # https://docs.djangoproject.com/en/3.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'channelsdb', } } # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/3.1/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/'
urls.py
from django.contrib import admin from django.urls import path, include, re_path from . import views urlpatterns = [ path('admin/', admin.site.urls), re_path('^auth/', include('djoser.urls')), re_path('^auth/', include('djoser.urls.jwt')), path('home', views.Home.as_view(), name='home'), ]
views.py
from rest_framework.views import APIView from rest_framework.response import Response from rest_framework.status import HTTP_200_OK class Home(APIView): def post(self, request): return Response({'data':'hello thanks for loggin' in'}, status=HTTP_200_OK)
Advertisement
Answer
This is a bug. It has been reported and fixed:
https://github.com/sunscrapers/djoser/issues/541
Happy coding.