Django:用户登录实例 一、源代码
1,login.html代码(登录界面):
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! --> <meta name="description" content=""> <meta name="author" content=""> <title>Login</title> <!--引入本地css & js--> <link rel="stylesheet" href="../static/style/app.css"/> </head> <body> <div class="container"> <form class="form-horizontal" action="/login/" method="post"> {% csrf_token %} <div class="control-group"> <label class="control-label" contenteditable="true" for="inputUser">用户</label> <div class="controls"> <input name="inputUser" placeholder="User" type="text" value="lizm" /> </div> </div> <div class="control-group"> <label class="control-label" contenteditable="true" for="inputPassword">密码</label> <div class="controls"> <input name="inputPassword" placeholder="Password" type="password" value="123456" /> </div> </div> <div class="control-group"> <div class="controls"> <label class="checkbox" contenteditable="true"> <input type="checkbox" /> Remember me </label> <button class="btn" contenteditable="true" type="submit">登陆</button> <span style="color:red;"> {{ status }}</span> </div> </div> </form> </div> <script type="text/javascript" src="../static/js/jquery-1.9.1.min.js"></script> <script type="text/javascript" src="../static/js/bootstrap.js"></script> </body> </html>