問題截圖:
解決辦法:
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、成功頁面