Django配置rest_framework 出现:身份认证信息未提供

问题截图:

 

解决办法:

1、在setting.py同级的urls.py文件中加入下面这条代码。

urlpatterns = [
    ....
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]

 

2、创建用户

aaa@aaa:~/Desktop/djtest$ python3 manage.py createsuperuser
System check identified some issues:

WARNINGS:
?: (rest_framework.W001) You have specified a default PAGE_SIZE pagination rest_framework setting, without specifying also a DEFAULT_PAGINATION_CLASS.
        HINT: The default for DEFAULT_PAGINATION_CLASS is None. In previous versions this was PageNumberPagination. If you wish to define PAGE_SIZE globally whilst defining pagination_class on a per-view basis you may silence this check.
用户名 (leave blank to use 'jett'): admin
电子邮件地址: 123@qq.com
Password: 
Password (again): 
密码长度太短。密码必须包含至少 8 个字符。
这个密码太常见了。
密码只包含数字。
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

 

3、访问页面出现登录的按钮,点击log in,用刚刚创建的用户登录。

 

 

4、成功页面

 

posted @ 2021-09-01 11:38  谢牧谚  阅读(1653)  评论(1编辑  收藏  举报