Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 超碰国产天天做天天爽,99免费在线,国产特黄特色a级在线视频

          整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          Django系統判斷用戶是否登錄的方法

          一種判斷用戶是否登錄

          class UserCenterView(View):
              # 第一種判斷用戶是否登錄
              def get(self, request):
                  # 判斷用戶是否登錄
                  if request.user.is_authenticated:
                      return render(request, 'user_center.html')
                  else:
                      response = redirect('/login/')
                      response.delete_cookie("username")
                      return response

          第二種判斷用戶是否登錄

          # urls.py 文件
          from django.contrib.auth.decorators import login_required
          url(r'^info/$', login_required(views.UserCenterView.as_view()), name="center"),
          
          view.py
          class UserCenterView(View):
          	
              # 第一種判斷用戶是否登錄
              def get(self, request):
                  # 判斷用戶是否登錄
                  return render(request, 'user_center.html')
          
          setting.py
          # 定義未登錄跳轉頁面
          LOGIN_URL = '/login/'

          第三種判斷用戶是否登錄

          from django.contrib.auth.mixins import LoginRequiredMixin
          class UserCenterView(LoginRequiredMixin,View):
          	login_url='/login/'
              # 第一種判斷用戶是否登錄
              def get(self, request):
                  # 判斷用戶是否登錄
                  return render(request, 'user_center.html')

          第四種判斷用戶是否登錄(自己封裝View)

          代碼:

          <html>

          <head>

          <title>if語句驗證用戶登錄</title>

          </head>

          <body>

          <table width="250" height="50" align="center" border="1">

          <form name="form1" method="post" action="">

          <tr>

          <td bgcolor="#eeeeee" bordercolor="#FFFFFF" bordercolordark="#CCCCCC" bordercolorlight="#FFFFFF"colspan="2" align="center">用戶登錄</td>

          </tr>

          <tr>

          <td width="150" align="center" valign="middle" >用戶名:</td>

          <td width="50"><input name="yan" type="text" maxlength="20"></td>

          </tr>

          <tr>

          <td align="center">密 碼:</td>

          <td><input name="pass" type="password" maxlength="10"></td>

          </tr>

          <tr>

          <td colspan="2"align="center"><input type="button" value="登陸" onClick="check()">

          <input type="reset" value="重置">

          </td>

          </tr>

          </table>

          </body>

          </html>

          <script language="javascript">

          function check(){

          if(form1.yan.value==""){

          alert("請輸入用戶名!");form1.yan.foucs();return;

          }else if(form1.pass.value==""){

          alert("請輸入密碼!");form1.pass.foucs();return;

          }

          else{

          form1.submit();

          }

          }

          </script>

          運行結果:

          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <title>登錄頁面</title>
              /*總體的樣式*/
              <style>
              	/*盒子樣式*/
                  #box{
                      width: 350px; //寬
                      height: 450px; //高
                      border: 1px solid black; //邊框
                      border-radius: 10px; //邊框弧度
                      font-family: 黑體; //字體
                      letter-spacing:8px; //段間距
                      word-spacing: 10px; //字間距
                      line-height: 40px; //行高
                      font-size: 18px; //字大小
                      padding: 20px; //內邊框
                  }
                  /*給'注冊'賦予樣式*/
                  .register{
                      width:280px ; //寬
                      height: 50px; //高
                      background-color: skyblue; //背景顏色
                      border-radius: 10px; //邊框弧度
          
                  }
                  /*將所有邊框都改變*/
                  *{
                      border-radius: 5px; 邊框弧度
                  }
                  /*使用class選擇器,賦予number寬高和邊框*/
                  .number{
                      width: 185px; //寬
                      height: 27px; //高
                      border-width: 1px; //邊框寬度
          
                  }
                  /*id選擇器*/
                  #two{
                      width: 55px; //寬
                      border-width: 1px; 邊框寬度
                  }
                  /*id選擇器*/
                  #phone{
                      width: 103px; //寬
                  }
                  /*class 選擇器*/
                  .boxs{
                      zoom: 75%; //清除浮動
                      color: darkgray; //顏色
                  }
                  /*class選擇器*/
                  .box_a{
                      width: 50px; //寬
                      height: 50px; //高
                      background-image: url("../image/04.jpg "); //背景圖片
                      background-repeat: no-repeat; // 是否平鋪
                      background-size: 50px 25px; //背景尺寸
                      position: relative; //定位 相對定位
                      left: 310px; //定位后左移
                      bottom: 32px; //定位后下移
          
                  }
              </style>
          </head>
          <body>
          <div id="box">
              <h1>請注冊</h1>
          <p style="color: darkgray">已有帳號?<a href="https://im.qq.com/index">登錄</a></p>
          <form action="" method="post">
              <label for="name">用戶名</label>
              <input type="text" placeholder="請輸入用戶名" id="name" class="number"> <br>
              <label for="phone">手機號</label>
              <select name="" id="two" class="number">
              <optgroup>
                  <option style="" class="">+86</option>
              </optgroup>
              </select>
              <input type="text" placeholder="請輸入手機號" id="phone" class="number"> <br>
              <label for="mima">密?碼</label>
              <input type="password" placeholder="請輸入密碼" id="mima" class="number"> <br>
              <label for="mima">驗證碼</label>
              <input type="password" placeholder="請輸入驗證碼" id="is" class="number">
              <div class="box_a"></div>
              <div class="boxs">
                  <input type="radio" id="" class="accept">閱讀并接受協議<br>
              </div>
              <input type="submit" value="注冊" class="register" >
          
              </form>
          </div>
          
          
          </body>
          </html>
          在這里插入圖片描述


          主站蜘蛛池模板: 乱子伦一区二区三区| 亚洲AV成人精品日韩一区18p | 日韩精品中文字幕无码一区| 精品国产一区二区三区香蕉事 | 国产一区二区三区韩国女主播| 精品国产日韩亚洲一区| 波多野结衣一区二区| 一区二区三区亚洲| 国模大尺度视频一区二区| 精品视频一区二区| 精品一区二区三区无码免费直播| 极品少妇一区二区三区四区| 搡老熟女老女人一区二区| 亚洲成AV人片一区二区密柚 | 无码人妻一区二区三区免费| 亚洲AV福利天堂一区二区三| 无码少妇一区二区| 久久一区二区精品综合| 国产成人精品一区二区三区免费 | 国产在线精品一区二区在线观看| 一本岛一区在线观看不卡| 一区二区三区免费视频网站| 日韩精品一区二三区中文| 一区二区免费国产在线观看| 亚洲AV永久无码精品一区二区国产| 人妻无码一区二区三区四区| 久久无码一区二区三区少妇 | 波多野结衣久久一区二区| 无码丰满熟妇浪潮一区二区AV| 日韩一区二区三区不卡视频| 老鸭窝毛片一区二区三区| 日韩动漫av在线播放一区| 精品一区二区三区四区在线| 亚洲国产一区二区a毛片| 国产精品久久久久久麻豆一区| 精品久久久久久中文字幕一区| 视频一区在线免费观看| 人妻少妇精品一区二区三区| 精品无码人妻一区二区免费蜜桃| 亚洲一区二区三区国产精华液| 婷婷亚洲综合一区二区|