- 论坛徽章:
- 0
|
模板
<html>
<head>
<title>用户账号为</title>
</head>
<body>
{% if aaa %}
<form method="post" action="/an/">
请输入要查询的角色名
<input type="text" name="aaa" value="">
<input type="submit" value="玩家账号查询">
</form>
{{ data1 }}
</body>
</html>
view.py
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
import MySQLdb
def userinfo(request):
zjj = request.POST.get('aaa',None)
if zjj:
db = MySQLdb.connect(user='root', db='sunyou', passwd='sunyou', charset='utf8',host='192.168.1.234')
cursor = db.cursor()
cursor.execute('SELECT name FROM account where id=(select acct from characters where name="wad")')
data1 = cursor.fetchall()
db.close()
return render_to_response('an.html',{'bbb':data1})
报错
ValueError at /an/
The view mysite.zhanghao.userinfo didn't return an HttpResponse object.
Request Method: GET
Request URL: http://127.0.0.1:8000/an/
Exception Type: ValueError
Exception Value: The view mysite.zhanghao.userinfo didn't return an HttpResponse object.
Exception Location: E:\Python25\Lib\site-packages\django\core\handlers\base.py in get_response, line 94
求救啊各位高人
ps:另外问下各位
django是如何区分一个页面里的不同的request的?
谢谢谢谢! |
|