首页 > 解决方案 > 我看不到 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',
}

任何提示将非常非常非常感谢:)

标签: django-rest-frameworkdjango-rest-authdjango-rest-framework-jwt

解决方案


添加rest_framework.renderers.BrowsableAPIRenderer到设置的默认渲染器类REST_FRAMEWORK

...
'DEFAULT_RENDERER_CLASSES': [
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
  ]
... 

推荐阅读