zoukankan      html  css  js  c++  java
  • django 验证密码

    <html>
    	<head>		
    <title>Index</title>
    		<link rel='stylesheet' type='text/css' href='/static/news/Css/Index/index.css'/>
    	</head>
    	<body>
    		<h1>泰隆运维管理平台</h1>
    		<!--图片标签-->
    		<img class="img_bk" src="/static/news/scan.jpg"/>
    		<!--表单提交-->
    		<form  class="form1" action="/main/" method="post" >
    			<table cellspacing="0" cellpadding="0">
    				<tr>
    					<td class="td1">用户名:</td>
    					<td><input type="text" name="username"/></td>
    					<td class="td3" ></td>
    					<td class="td4"></td>
    				<tr/>
    				<tr>
    					<td class="td1">密码:</td>
    					<td><input type="password" name="password"/></td>
    					<td class="td3"></td>
    					<td class="td4"></td>
    				<tr/>
    				<!-- <tr> -->
    					<!-- <td class="td1">验证码:</td> -->
    					<!-- <td>   <input type='text' name='code' /></td> -->
    					<!-- <td class="td3"><img src="__APP__/Public/code" onclick='this.src=this.src+"?"+Math.random()'/></td> -->
    					<!-- <td class="td4"></td> -->
    				<!-- </tr> -->
    				<tr>
    					<td class="td1"></td>
    					<td><input type="submit" value="" name="imgLogin" /></td>
    					<td class="td3"></td>
    					<td class="td4"></td>
    				</tr>
    			</table>
    		</form>
    	</body>
    </html>
    
    
    
    System check identified no issues (0 silenced).
    
    You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): news.
    Run 'python manage.py migrate' to apply them.
    
    September 13, 2018 - 21:08:21
    Django version 1.11.9, using settings 'mysite.settings'
    Starting development server at http://0.0.0.0:9000/
    Quit the server with CONTROL-C.
    None
    The username and password were incorrect.
    Internal Server Error: /main/
    Traceback (most recent call last):
      File "/usr/local/python27/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
        response = get_response(request)
      File "/usr/local/python27/lib/python2.7/site-packages/django/core/handlers/base.py", line 198, in _get_response
        "returned None instead." % (callback.__module__, view_name)
    ValueError: The view news.views.main didn't return an HttpResponse object. It returned None instead.
    [13/Sep/2018 21:08:26] "POST /main/ HTTP/1.1" 500 58587
    
    
    
    def main(req):
       user=req.POST['username']
       print user
       passwd=req.POST['password']
       print passwd
       from django.contrib.auth import authenticate
       user = authenticate(username=user, password=passwd)
       print user
       if user is not None:
        # the password verified for the user
        if user.is_active:
            print("User is valid, active and authenticated")
        else:
            print("The password is valid, but the account has been disabled!")
       else:
        # the authentication system was unable to verify the username and password
        print("The username and password were incorrect.")
    
  • 相关阅读:
    Springboot构建问题集
    常用算法解析技巧总结
    Linux、Docker安装Nginx
    MySQL查询语句报错 sql_mode=only_full_group_by 问题
    MySQL按周统计 WEEK 实例
    IDEA注册码分享
    Mock测试接口
    Maven常用命令
    js中的for循环,循环次数会多出一次。当循环到最后一个的时候,循环还会继续,并且此时i就变成remove?
    vue .sync的理解
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349042.html
Copyright © 2011-2022 走看看