锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产91成人精品亚洲精品,亚洲综合精品伊人久久,久久久久亚洲AV无码专区体验http://m.tkk7.com/stingh711/category/26267.htmlzh-cnSat, 17 Nov 2007 22:09:47 GMTSat, 17 Nov 2007 22:09:47 GMT60My first ajax app using django and jqueryhttp://m.tkk7.com/stingh711/archive/2007/11/16/161014.htmldjangodjangoFri, 16 Nov 2007 06:48:00 GMThttp://m.tkk7.com/stingh711/archive/2007/11/16/161014.htmlhttp://m.tkk7.com/stingh711/comments/161014.htmlhttp://m.tkk7.com/stingh711/archive/2007/11/16/161014.html#Feedback0http://m.tkk7.com/stingh711/comments/commentRss/161014.htmlhttp://m.tkk7.com/stingh711/services/trackbacks/161014.htmlRequirement:
There is a simple form that has two input field, one is zip code and another is city. If the zip code is filled, the page will fill the city automatically by getting the relevant city of the zip code in an AJAX way.

Implementation:
1. django-admin.py startproject study
2. cd study
3. python manage.py startapp ajax
4. Edit settings.py, add 'study.ajax' to INSTALLED_APPS.
5. mkdir site_media
6. Download jquery.js from www.jquery.com and copy it to site_media
7. Add the following line to urls.py:
(r'^site_media/(?P<path>.*)$',聽'django.views.static.serve',聽{'document_root':'/home/sting/Django/study/site_media'}),
聽 Note: We will include jquery.js in our html, for this kind of static files, django's handling is different from others. Please see http://www.djangoproject.com/documentation/static_files/ to get more detailed information.
8. cd ajax
9. mkdir templates
聽 Note: This folder is used to put template files. It seems that django can load template files from this folder automatically, so you needn't to configure it in settings.py.
10. Create the following html file named form.html.
<!DOCTYPE聽HTML聽PUBLIC聽"-//W3C//DTD聽HTML聽4.01//EN"聽"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Register聽form</title>
<script聽src="http://localhost:8000/site_media/jquery.js"聽type="text/javascript"></script>
<script聽type="text/javascript">
聽聽
function聽getZipData()聽{
聽聽聽聽
var聽zipcode聽=聽$('#zip').val();
聽聽聽聽$.get('http:
//localhost:8000/ajax/getzipdata/'聽+聽zipcode聽+聽'/',聽function(data)聽{
聽聽聽聽聽聽$('#city').attr({'value':data});
聽聽聽聽});
聽聽}
</script>
</head>
<body>
<table>
<form聽actioon=""聽method="post">
<tr><td>Zip:</td><td><input聽id="zip"聽onblur="getZipData()"聽type="text"聽name="zip"/></tr>
<tr><td>City:</td><td><input聽id="city"聽type="text"聽name="city"/></tr>
</form>
</table>
</body>
</html>
11. Edit views.py and add the following methods.
from聽django.http聽import聽HttpResponse
from聽django.core聽import聽serializers
from聽django.shortcuts聽import聽render_to_response

def聽getzipdata(request,聽zipcode):
聽聽
if聽zipcode聽=='214028':
聽聽聽聽city聽
='wuxi'
聽聽
else:
聽聽聽聽city聽
=''

聽聽
return聽HttpResponse(city)

def聽register(request):
聽聽
return聽render_to_response('form.html',聽{})
12. Add the following lines to urls.py.
(r'^ajax/register/$',聽'study.ajax.views.register'),
(r
'^ajax/getzipdata/(\d+)/$',聽'study.ajax.views.getzipdata'),

Visit http://localhost:8000/ajax/register/, you will see the simple form, after fill the zip code and move to city, the city will be filled automatically.

Blogged with Flock

Tags: , , ,



django 2007-11-16 14:48 鍙戣〃璇勮
]]>
IPython, an enhanced python &quot;shell"http://m.tkk7.com/stingh711/archive/2007/11/06/158589.htmldjangodjangoTue, 06 Nov 2007 08:32:00 GMThttp://m.tkk7.com/stingh711/archive/2007/11/06/158589.htmlhttp://m.tkk7.com/stingh711/comments/158589.htmlhttp://m.tkk7.com/stingh711/archive/2007/11/06/158589.html#Feedback0http://m.tkk7.com/stingh711/comments/commentRss/158589.htmlhttp://m.tkk7.com/stingh711/services/trackbacks/158589.html
  • Auto completion with "Tab". For example, s is a string, if you press "Tab" after "s.", all methods of Python string will be listed, just like the auto completion in my konsole.
  • Auto indent.
  • IPython will add parentheses to functions and methods. For example, dir '' is the same with dir('')
  • Magic commands. Common used shell commands are also available in IPython shell, such as "cd", "ls", "mkdir". Another two magic commands are very useful. The first one is "edit". In IPython shell, command "edit xxx" will invoke vim to edit the xxx file. (Vim is the default editor and emacs is supported too.) Another useful command is run. You can use command "run xxx.py" to run xxx. There are lots of other magic commands that I haven't tested. You can use command "lsmagic" to list them.
  • Dynamic object information. Type "?word" and "??word" prints detailed information about an object.
  • System shell access. Any shell commands can be used in IPython by add "!" in the front. For example, "!ifconfig" will pass "ifconfig" to the shell directly.
  • There are many other features like "session logging and restoreing", "Input and output caching" that I haven't tested yet. If you are learning Python, I strongly recommend it to you.
    Let's try it together!

    Blogged with Flock

    Tags:



    django 2007-11-06 16:32 鍙戣〃璇勮
    ]]>
    主站蜘蛛池模板: **aaaaa毛片免费同男同女| 国产亚洲福利精品一区二区| 99久久婷婷免费国产综合精品| 日本免费电影一区| 无码天堂va亚洲va在线va| 噼里啪啦电影在线观看免费高清 | 久久综合国产乱子伦精品免费| 亚洲va无码专区国产乱码| 久久免费线看线看| 亚洲日本视频在线观看| 国产91免费视频| 一本色道久久综合亚洲精品蜜桃冫| 无码高潮少妇毛多水多水免费| 亚洲精品无码国产片| 免费h成人黄漫画嘿咻破解版| 边摸边吃奶边做爽免费视频网站| 亚洲精品无码专区久久同性男| 热99RE久久精品这里都是精品免费| 国产亚洲精AA在线观看SEE| 最近新韩国日本免费观看 | 人人狠狠综合久久亚洲婷婷| 久久综合给合久久国产免费| 亚洲综合丁香婷婷六月香| 国产公开免费人成视频| 国产视频精品免费视频| 91久久亚洲国产成人精品性色 | 亚洲日韩久久综合中文字幕| 成人亚洲网站www在线观看 | 免费观看亚洲人成网站| 亚洲日韩精品一区二区三区无码 | 亚洲第一视频在线观看免费| 亚洲激情在线视频| 在线观看人成网站深夜免费| EEUSS影院WWW在线观看免费| 亚洲日韩乱码久久久久久| 全黄性性激高免费视频| 久久久免费精品re6| 另类小说亚洲色图| 亚洲色偷偷av男人的天堂| 日韩免费视频播放| 久久国产乱子伦精品免费强|