<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
label{
width:80px;
text-align:right;
display: inline-block;
}
</style>
</head>
<body> <form action="/login" method="post">
<p>
<label for="username">用户名:</label>
<input id="username" type='text'/>
</p>
<p>
<label for="password">密码:</label>
<input id="password" type='text'/>
<input type="submit" value="提交"/>
</p>
</form> </body>
</html>

login.html

 from django.shortcuts import render

 # Create your views here.

 from django.shortcuts import HttpResponse

 def login(request):
f = open('templates/login.html','r',encoding='utf-8')
data = f.read()
f.close()
return HttpResponse(data)

views.py

 """S14Djngo URL Configuration

 The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin from cmdb import views urlpatterns = [
url(r'^admin/', admin.site.urls),
#url(r'^h.html/',views.home),
url(r'^login',views.login),
]

urls.py

打开浏览器访问: http://127.0.0.1:8009/login

Django与HTML业务基本结合--基本的用户名密码提交方法1的更多相关文章

  1. Django与HTML业务基本结合--基本的用户名密码提交方法2

    from django.shortcuts import render # Create your views here. from django.shortcuts import render de ...

  2. Django修改用户名密码的方法

    1.python manage.py shell 2.from django.contrib.auth.models import User 3.user=User.objects.get(usern ...

  3. Django用户名密码错误提示

    from django.shortcuts import render # Create your views here. from django.shortcuts import render fr ...

  4. Django后端向前端直接传html语言防止转义的方法(2种)

    Django后端向前端直接传html语言防止转义的方法(2种) 目的,为了让前端对后端传输的这种方式不转义 1.使用mark_safe() from django.utils.safestring i ...

  5. 利用Django和装饰器做一个简单的修改密码页面

    view视图代码: from django.shortcuts import render,redirect from django.http import HttpResponse from PIL ...

  6. Django 分页查询并返回jsons数据,中文乱码解决方法

    Django 分页查询并返回jsons数据,中文乱码解决方法 一.引子 Django 分页查询并返回 json ,需要将返回的 queryset 序列化, demo 如下: # coding=UTF- ...

  7. Django加入JS,CSS,图片等外部文件的方法

    Django加入JS,CSS.图片等外部文件的方法 By 白熊花田(http://blog.csdn.net/whiterbear) 转载需注明出处,谢谢. 在使用Django搭建站点时,往往须要使用 ...

  8. Django与HTML业务基本结合

    app里都有migrations文件 app: migrations 数据修改表结构,数据库操作记录 admin Django为我们提供后台管理 apps 配置当前app models ORM,写指定 ...

  9. 关于celery django django-celery版的搭配的报错问题及解决方法

    G:\python3_django\DFpro\mypro (win)(py3_django) λ python manage.py celery worker --loglevel=infoTrac ...

随机推荐

  1. day 47 前端基础之BOM和DOM

      前端基础之BOM和DOM   前戏 到目前为止,我们已经学过了JavaScript的一些简单的语法.但是这些简单的语法,并没有和浏览器有任何交互. 也就是我们还不能制作一些我们经常看到的网页的一些 ...

  2. 短URL系统、301/302重定向

    短 URL 系统是怎么设计的?https://yq.aliyun.com/articles/87600 短网址(short URL)系统的原理及其实现 https://hufangyun.com/20 ...

  3. 795. Number of Subarrays with Bounded Maximum

    数学的方式 是对于所有的字符分成简单的三类 0 小于 L 1 LR 之间 2 大于R 也就是再求 不包含 2 但是包含1 的子数组个数 不包含2的子数组个数好求 对于连续的相邻的n个 非2类数 就有 ...

  4. 乐观、悲观锁、redis分布式锁

    悲观锁总是假设最坏的情况,每次去拿数据的时候都认为别人会修改,所以每次在拿数据的时候都会上锁,这样别人想拿这个数据就会阻塞直到它拿到锁(共享资源每次只给一个线程使用,其它线程阻塞,用完后再把资源转让给 ...

  5. tDQSS

    tDQSS - DQS latching rising transitions to associated clock edges, as described on Table 41/42 of JE ...

  6. 19-10-25-G-悲伤

    此题未通过 [ 老帅哥 ] 认证. ZJ一下: T1,明显是二分答案+$dij/SPFA$ T2,没看懂题. T3,打了一个$\Theta(N^2)$暴力. 事实上…… T1,T2死了. T1中 每次 ...

  7. ie浏览器将网页转成pdf

    今天同事让我帮他将网页转成pdf,学了一个.先推荐一个超图的数据库使用指南:http://support.supermap.com.cn/DataWarehouse/WebDocHelp/6.1.1/ ...

  8. SpringMVC配置顺序的问题

    1:web.xml:web应用一经加载,先来找他         1):指明applicationContext的位置         2):引入spring监听,ContextLoaderListe ...

  9. PAT甲级——A1055 The World's Richest

    Forbes magazine publishes every year its list of billionaires based on the annual ranking of the wor ...

  10. 【DM642学习笔记八】色度重采样

    TI文档"TMS320C64x DSP Video Port_VCXO Interpolated Control (VIC)Port.pdf"第3.5.2 Chrominance ...