小编Mas*_*mas的帖子

'str' 对象在 djangorestframework_simplejwt 上没有属性 'decode'

我试图通过链接https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html遵循 djangorestframework-simplejwt 文档的快速入门

但是我在尝试获取令牌时遇到问题,并且总是返回此错误 'str' object has no attribute 'decode'

在此输入图像描述

编辑: 这是我在 urls.py 上的代码

from django.contrib import admin
from django.urls import path
from rest_framework_simplejwt import views as jwt_views
from core.views import HelloView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/token/', jwt_views.TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', jwt_views.TokenRefreshView.as_view(), name='token_refresh'),
    path('hello/', HelloView.as_view(), name='hello'),
]
Run Code Online (Sandbox Code Playgroud)

设置.py

...
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
]
...
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ],
}
...
Run Code Online (Sandbox Code Playgroud)

视图.py

from django.shortcuts import render

# Create your views …
Run Code Online (Sandbox Code Playgroud)

django jwt django-rest-framework

12
推荐指数
1
解决办法
9248
查看次数

GCP Cloud Logging 花费如此之大,如何禁用它?

GCP Billing Cloud 日志记录指标

您好,我想问一下为什么Cloud Logging服务要花这么多费用,Cloud Logging是如何工作的?我想通过引用此链接来禁用https://cloud.google.com/resource-manager/docs/organization-policy/disabling-cloud-logging但出现错误。

禁用云日志记录 gcp 时出错

google-cloud-storage google-cloud-platform google-cloud-logging

5
推荐指数
1
解决办法
6047
查看次数