get方法返回login.html

users/views.py

def login(request):
if request.method == "POST":
pass
elif request.method == "GET":
return render(request, "login.html") 前端请求发来request对象里包含了method,path等.
可以debug单步调试看到
users/urls.py

from users import views

urlpatterns = [
path('', TemplateView.as_view(template_name='index.html'), name="index"),
path('login/', views.login, name="login"),
path('xadmin/', xadmin.site.urls),
]

前端页面

templates/index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>index</title>
<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<div>
<p><a href="/login">登录</a></p>
<p><a href="/register">注册</a></p>
</div>
<script src="/static/js/jquery-3.3.1.min.js"></script>
</body>
</html>

templates/login.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>login</title>
</head>
<body>
<div>
<form action="/login" method="post">
<p><input type="text" name="username" placeholder="username"></p>
<p><input type="text" name="password" placeholder="password"></p>
<p><input type="submit"></p>
</form>
</div>
</body>
</html>

[py][mx]django get方法返回login页面的更多相关文章

  1. [py][mx]django使用class写views-免去判断方法的烦恼

    修改views使用class模式 类模式写views - 免去了函数模式的判断的烦恼 users/views.py from django.views.generic import View clas ...

  2. [py][mx]django form验证-给db减压

    django form认证-解压db压力 一般系统都需要前后端都验证 前端验证容器逃逸破解,如通过js console口去发 试想如果后端只有db验证,那么前端无论发什么后端都查询一次db,对db压力 ...

  3. [py][mx]django自定义认证类-实现邮箱作为用户名登录

    创建自定义验证用户名密码类CustomBackend users/views.py from django.contrib.auth import authenticate, login from d ...

  4. [py][mx]django处理登录逻辑

    浏览器同源策略(same-origin policy) csrf攻击防御核心点总结 django的cookie和session操作-7天免登录 flask操作cookie&django的see ...

  5. [py][mx]django模板继承-课程列表页

    课程列表页分析 1,机构类型 2,所在地区 3.排序 学习人数 先分析下 纵观页面,页头页脚都一样. django提供了模板继承. 至少 不同页面的title 面包屑路径 content内容不一致,以 ...

  6. [py][mx]django课程页显示city和机构封面图

    city和课程机构信息展示到前台去 organization/views.py from django.views.generic.base import View from organization ...

  7. [py][mx]django xadmin后台配置

    xadmin配置 - 安装 pip install -r https://github.com/sshwsfc/xadmin/blob/django2/requirements.txt 以下被我测试通 ...

  8. [py][mx]django项目-让系统用自定义的users表认证

    项目开端 参考的是mxonline项目 先把这两项完成 1.app设计 2.app的models的设计 经过分析系统有四个模块 users - 用户管理 course - 课程管理 oranizati ...

  9. [py][mx]django静态文件目录配置

    使用TemplateView直接返回html from django.views.generic import TemplateView urlpatterns = [ path('',Templat ...

随机推荐

  1. 清空Cookie

    function delCookie() { ; i < cookies.length; i++) { try { document.cookie = cookies[i] + "=0 ...

  2. 【推荐系统论文笔记】Introduction To Recommender Systems: Algorithms and Evaluation

    这篇论文比较短,正如题目所说,主要还是简单地介绍了一下推荐系统的一些算法以及评估的方法. 推荐系统之前是基于关键字信息的过滤系统,后来发展成为协同过滤系统,解决了两个问题:1.通过人工审核去评价那些具 ...

  3. 题目1440:Goldbach's Conjecture(哥达巴赫猜想)

    题目链接:http://ac.jobdu.com/problem.php?pid=1440 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

  4. [转]RedHat Enterprise Linux 7关闭防火墙方法

    在之前的版本中关闭防火墙等服务的命令是 service iptables stop /etc/init.d/iptables stop 在RHEL7中,其实没有这个服务 [root@rhel7 ~]# ...

  5. 3-1 vue-resource基础介绍

    1.静态引用 <script src="https://cdn.bootcss.com/vue-resource/1.3.4/vue-resource.js">< ...

  6. kvm虚拟机的重命名

    1.查看所有的kvm虚拟机 [root@5201351_kvm ~]# virsh list --all 2.重命名kvm虚拟机最好是将虚拟机先关机,然后再导出其xml文件 [root@5201351 ...

  7. 关于Jmeter3.0,你必须要知道的5点变化

    2016.5.18日,Apache 发布了jmeter 3.0版本,本人第一时间上去查看并下载使用了,然后群里或同事都会问有什么样变化呢?正好在网上看到一遍关于3.0的文章,但是是英文的.这里翻译一下 ...

  8. 使用Wireshark分析QQ聊天

  9. yii---where or该如何使用

    今天调试YII项目的时候,遇到一个奇葩的事儿,在调试 where or 查询的时候:调试语句是这样: $str = static::find()->where(['or','username' ...

  10. Nginx设置网站维护页面

    网站升级需要停服,可以在Nginx设置静态页面设置强制跳转 修改nginx配置文件nginx.conf http { sendfile on; keepalive_timeout 65; server ...