首页 > 代码库 > 一个初学者的辛酸路程-基于Django写BBS项目
一个初学者的辛酸路程-基于Django写BBS项目
前言
基于Django的学习
详情
登录界面
def login(request): errors = {} if request.method == "POST": username = request.POST.get("username") password = request.POST.get("password") user = authenticate(username=username,password=password) print("auth res",user) if user: print("authenticate success") return redirect("/") else: errors = {"error":"用户名或者密码错误"} return render(request,‘login.html‘,errors) URL url(r‘^login$‘, views.login,name="login"), HTML {% extends ‘base.html‘ %} {% block body %} <div class="container"> <div class="col-lg-3 col-lg-offset-4"> <form class="form-signin" method="POST"> <h2 class="form-signin-heading">抽屉热门社区</h2> <label for="inputEmail" class="sr-only">用户名</label> <input type="text" name="username" id="inputEmail" class="form-control" placeholder="username" required autofocus> <label for="inputPassword" class="sr-only">Password</label> <input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required> <span style="color: red;">{{ error }}</span> <div class="checkbox"> <label> <input type="checkbox" value=http://www.mamicode.com/"remember-me"> Remember me </label> </div> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> </form> </div> </div> {% endblock %}
-
{% extends ‘base.html‘ %} {% block body %} <div class="container"> <div class="col-lg-3 col-lg-offset-4"> <form class="form-signin" method="POST"> <h2 class="form-signin-heading">抽屉热门社区</h2> <label for="inputEmail" class="sr-only">用户名</label> <input type="text" name="username" id="inputEmail" class="form-control" placeholder="username" required autofocus> <label for="inputPassword" class="sr-only">Password</label> <input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required> <span style="color: red;">{{ error }}</span> <div class="checkbox"> <label> <input type="checkbox" value=http://www.mamicode.com/"remember-me"> Remember me </label> </div> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> </form> </div> </div> {% endblock %}
-
def index(request): return redirect("/category/1/")
一个初学者的辛酸路程-基于Django写BBS项目
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。