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、成功頁面

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM