django实现获取用户输入方法,django实现获取用户,这是用django实现的
django实现获取用户输入方法,django实现获取用户,这是用django实现的
这是用django实现的获取用户输入方法示例。
#urls.pyfrom django.conf.urls.defaults import *from mysite.views import search , result# Uncomment the next two lines to enable the admin:# from django.contrib import admin# admin.autodiscover()urlpatterns = patterns('', # Example: # (r'^mysite/', include('mysite.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^$', search), (r'^search/$', result))
#views.py#-*- coding: UTF-8 -*-from django.shortcuts import render_to_responsedef search(request): return render_to_response('search.html')def result(request): key = request.GET['q'] if not key : message = u'请输入搜索内容' return render_to_response('result.html',{'message':message}) else : message = u'你输入的是' + key return render_to_response('result.html',{'message':message})<html><!--search.html--><head> <title>Search</title></head><body> <form action="/search/" method="get"> <input type="text" name="q"> <input type="submit" value="Search"> </form></body></html><html><!--result.html--><head> <title>Search</title></head><body> {{message}}</body></html>
编橙之家文章,
相关内容
- python自动登录并备份文件操作,python自动登录备份,py
- Python发可以带附件的email操作方法分享,pythonemail,Pyth
- python面向过程的简单通讯录示例,python通讯录示例,初学
- Python数据库sqlite3的基本应用,python数据库sqlite3,Python数
- 显示py文件类名和函数的方法,py文件类函数,这是一个
- 下载游戏IP座标等信息的python方法,游戏ip座标python,下
- Python FTP破解小工具源码,pythonftp破解源码,Python FTP破解
- Python正态分布概率计算方法,python概率计算方法,Pytho
- 请大牛指点将List转成XML代码问题,大牛xml,近期正在学
- Python斐波那契数列简单实现源码,python斐波那契数列
评论关闭