django-rest-framework - 我看不到 DRF api 确认浏览器
问题描述
我通过邮递员检查了api操作。
我不知道是什么问题..
我认为代码没有问题
这是我的代码项目文件夹 urls.py
url(r'^', include('django.contrib.auth.urls')),
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
url(r'^account/', include('allauth.urls')),
url(r'^accounts-rest/registration/account-confirm-email/(?P<key>.+)/$',
confirm_email, name='account_confirm_email'),
设置.py
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
# 'rest_framework.permissions.IsAuthenticated',
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
),
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
],
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
],
}
REST_AUTH_SERIALIZERS = {
'USER_DETAILS_SERIALIZER': 'accounts.serializers.UserSerializer',
}
任何提示将非常非常非常感谢:)
解决方案
添加rest_framework.renderers.BrowsableAPIRenderer
到设置的默认渲染器类REST_FRAMEWORK
。
...
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
]
...
推荐阅读
- c# - 设置精度 c#
- javascript - Firestore 安全规则允许公开一个文档
- java - 当只给出 y 截距和斜率时,是否可以检查点“x”和“y”是否在一条线上?
- plugins - Jekyll 需要两个版本的同一个 gem
- c# - 如何更新 Entity Framework Core 中的单个属性
- android - 如何使用套接字从服务器读取数据?
- java - Java - 在某些集合方法规范中真的需要“扩展对象”吗?
- ruby-on-rails - 参数丢失或值为空:活动 Rails 4
- php - 如何从 Woocommerce 中的订单项目中获取产品 sku
- html - 需要背景大小属性的帮助