普通版手写注册
def register(request): errors = {‘name‘:‘‘,‘pwd‘:‘‘} if request.method == ‘POST‘: name=request.POST.get(‘name‘) pwd=request.POST.get(‘pwd‘) if ‘sb‘ in name: errors[‘name‘] = ‘名字中不能有"sb"‘ if len(pwd)<6: errors[‘pwd‘] = ‘密码长度至少6位‘ return render(request,‘reg.html‘,locals())
<body> <h3>注册</h3> <form action="" method="post"> <p>username: <input type="text" name="name"> <span>{{ errors.name }}</span> </p> <p>password: <input type="password" name="pwd"> <span>{{ errors.pwd }}</span> </p> <input type="submit"> </form> </body>
原文:https://www.cnblogs.com/pdun/p/10752254.html