1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#get方式
<!DOCTYPE html>
<html>
<head>
<meta charset
=
"utf-8"
>
<title>this
is
get test<
/
title>
<
/
head>
<body>
<form action
=
"/search/"
method
=
"get"
>
<
input
type
=
"text"
name
=
"guanjianzi"
>
<
input
type
=
"submit"
value
=
"搜索"
>
<
/
form>
<
/
body>
<
/
html>
##########################
def
Auth(request):
print
request.GET
#返回的是字典
username,password
=
request.GET[
"username"
],request.GET[
"passwd"
]
if
username
=
=
"wangjiadongge"
and
password
=
=
"chen1314"
:
return
HttpResponse(
"the usernmame and password is correct "
)
else
:
return
HttpResponse(
"the username and password is incorrect"
)
#post方式:
<!DOCTYPE html>
<html>
<head>
<meta charset
=
"utf-8"
>
<title>this
is
post test<
/
title>
<
/
head>
<body>
<form action
=
"/search/"
method
=
"post"
>
{
%
csrf_token
%
}
<
input
type
=
"text"
name
=
"guanjianzi"
>
<
input
type
=
"submit"
value
=
"提交"
>
<
/
form>
<p>{{ xianshi }}<
/
p>
<
/
body>
<
/
html>
########
from
django.shortcuts
import
render
from
django.views.decorators
import
csrf
def
Post(request):
shuju
=
{ }
shuju[
'xianshi'
]
=
request.POST[
'guanjianzi'
]
print
shuju
return
render(request,
"post.html"
,shuju)
|
本文转自 王家东哥 51CTO博客,原文链接:http://blog.51cto.com/xiaodongge/1931375