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 国产成人免费网站在线观看,欧美成人观看视频在线,久久久久久久久免费视频

          整合營銷服務商

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

          免費咨詢熱線:

          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>
          在這里插入圖片描述


          主站蜘蛛池模板: 国产无人区一区二区三区| 久久精品无码一区二区三区免费 | 亚洲线精品一区二区三区| 国产精品久久久久久麻豆一区| 国产亚洲一区区二区在线| 无码人妻精品一区二区蜜桃| 久久国产精品免费一区二区三区 | 一区二区在线电影| 一区二区三区亚洲视频| 国产精品日韩一区二区三区| 国产美女一区二区三区| 亚欧在线精品免费观看一区| 久久精品视频一区| 国产成人无码一区二区三区| 伦理一区二区三区| 伊人色综合一区二区三区| 97精品国产福利一区二区三区| 一区二区三区无码高清| 日本一区二区三区在线视频观看免费 | 久久精品国产一区二区三区不卡 | 99精品国产高清一区二区麻豆| 亚洲av不卡一区二区三区| 日本一区二区不卡在线| 国模吧一区二区三区| 一区二区三区亚洲| 日本一区二区三区爆乳| 欧美亚洲精品一区二区| 国产怡春院无码一区二区| 日韩一区二区三区免费体验| 成人丝袜激情一区二区| 国产伦精品一区二区| 亚洲国产精品一区二区九九 | 国产一区二区在线视频| 日本在线一区二区| 日韩精品无码一区二区三区不卡| 久久免费区一区二区三波多野| 国产一区韩国女主播| 一区二区不卡视频在线观看| 国产精品成人免费一区二区| 国产91精品一区二区麻豆网站 | 中文字幕一区二区三区人妻少妇 |