1、創(chuàng)建HTML
在HelloWorld根目錄下創(chuàng)建templates文件夾

創(chuàng)建templates.png
并在文件夾中創(chuàng)建login.html文件,編輯html文件

編輯html文件.png
2、編輯Login函數(shù)
在api_test/views.py文件里,編輯Login函數(shù)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
from django.http.response import HttpResponse
from django.shortcuts import render_to_response
# Create your views here.
def Login(request):
if request.method == 'POST':
username = request.POST.get('username')
return HttpResponse(username)
else:
return render_to_response('login.html')
3、添加html路徑并關(guān)閉認(rèn)證

添加html路徑.png

關(guān)閉認(rèn)證.png
4、重啟服務(wù)并使用瀏覽器訪問(wèn)
#python manage.py runserver 8001
使用瀏覽器訪問(wèn),輸入用戶名和密碼,并點(diǎn)擊登錄按鈕

瀏覽器訪問(wèn).png
登錄后,顯示為:

圖片.png