<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Requirement:
    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: , , ,

    posted @ 2007-11-16 14:48 django 閱讀(2418) | 評(píng)論 (4)編輯 收藏
     

    Fun with Idioms: in light of

    In light of this new piece of evidence, I must proclaim the defendant "not guilty".

    In light of latest news, we have decided to close our factories in Argentina.

    Confusing Words: cure vs heal

    You cannot cure the common cold.
    The cut on my arm healed in a week.
    Cure: To stop someone from being affected by an illness.

    Heal: If an injury heals, the skin or bone grows back together and becomes healthy again.
    For example:
    The doctor cured the patient of his disease.
    Is it possible to cure cancer?
    The cut will never heals.
    How long will my broken leg take to heal?

    How to say it in English:

    • 這是商務(wù)倉(cāng)的登機(jī)柜臺(tái)么?
      • Is this the check-in counter for business class?
    • Is this where I check in for business class?
    • Does this counter server business class customers?
    • 這班班機(jī)到底會(huì)誤點(diǎn)多少?
    • Exactly how long is this flight going to be delayed?
    • How late will this plane be?
    • Can you tell me how long the delay will be for my flight?
    • 今天所有飛北京的班機(jī)都客滿(mǎn)了.
    • All of flights to Beijing today are full.
    • Today's flights to Beijing are completely booked.
      • There are no available seats on any flight to Beijing today.

    Blogged with Flock

    Tags: ,

    posted @ 2007-11-15 23:05 django 閱讀(285) | 評(píng)論 (0)編輯 收藏
     
    This doesn't always happen.

    The note is only a reminder.

    She must be at least thirty-five years old.
    She must be a teacher.
    The student must have called you yesterday.
    Darling, it must be terrible to be grown up.

    It is impossible to find the thief.
    It is easy to kick a man that is down.

    Did you have a good meal?
    Did you have a good stay?

    Can I return these two tickets?
    Could you come here for a moment?
    Shall I take a look at the new furniture?

    I might as well have them.
    You might as well forget her.
    You might as well come here and have a look.

    Over a hundred people must have been driven away from their homes by the noisy.
    The urgent notice must have been seen.

    Blogged with Flock

    Tags:

    posted @ 2007-11-15 00:04 django 閱讀(273) | 評(píng)論 (0)編輯 收藏
     
    She is the cleverest girl of the six children.
    He drivers fastest in his family.

    We waited and waited.
    The red army walked and walked.

    You have belonged to me for a long time.

    I am at last persuaded by him.

    I was having dinner at a restaurant when Tony came in.
    I was reading a newspaper when I saw a funny picture.
    He was still smiling when the door opened and his wife came in.

    Tony saw me and came and sat at the same table.
    He opened the door and stepped on a banana skin and fell down.

    He asked the guests to feel at home.
    His friends all encouraged him to take the challenge.
    The thief begged the policemen to let him off.
    Now we are not allowed to touch it.

    -Thanks for the meal. I enjoyed it very much! But I'm afraid I must be leaving.
    -Not at all. I'm glad you could come. Drop in again whenever you want.
    -You must come and have a meal with me some time.
    -Yes. That would be nice.

    Don't pretend.
    Never do it again.
    Never cry uncle.
    Don't beat about the bush and tell us the truth.
    Stop being worried about your weight.

    Blogged with Flock

    Tags:

    posted @ 2007-11-12 21:31 django 閱讀(309) | 評(píng)論 (0)編輯 收藏
     
    Pinhurst is only five miles from Silbury.
    My home is two miles and a half away from the company.
    Guangzhou is only a fifty-minute bus-ride away from shenzhen.
    The zoo is a twenty-minute walk away from here.
    The United States is a long way east of China.

    While two detectives were keeping guard at the door, two others opened the parcel.
    While I was waiting for the train, I met my old friend by accident.
    I was watching him while he was watching the kids.

    To his surprise, the precious parcel was full of stones and sand.
    To everybody's disappointment, the concert was a failure.
    To the circus owner's pleasure, the local government presented the circus with a baby elephant called Jumbo.
    To citizen's satisfaction, fireman put out the fire within 3 hours.

    Generally speaking/Frankly speaking/Fortunately/To be honest/To make matters worse/To sum up

    Blogged with Flock

    Tags:

    posted @ 2007-11-11 20:06 django 閱讀(277) | 評(píng)論 (0)編輯 收藏
     
    I could not bear it.
    I could not bear it anymore.
    It was more than I could bear it.
    It is as far as I could
    bear it.

    It's none of your business.
    Mind your own business.
    Get out, f**k yourself.
    Don't put your finger in my pie.

    What a day!
    What a beauty!
    How I like the film!

    From there, he will fly to Perth.
    My parents used to live in South America and I used to fly there from Europe in the holidays. Just then, a man hurried to the ticket office.

    So he is finding this trip very interesting.
    I find him friendly.
    I find his words totally meaningless.

    Blogged with Flock

    Tags:

    posted @ 2007-11-09 00:10 django 閱讀(270) | 評(píng)論 (0)編輯 收藏
     
    • Repeat last changes: "." command can be used to repeat simple text changes in normal mode.
    • Swap two characters: xp
    • Swap two lines: ddp
    • Switch case of characters:
      • ~: switch case of character under cursor
      • g~~: switch case of current line
      • gUU: make current line uppercase
      • guu: make current line lowercase
      • gUaw: make current word uppercase
      • guaw: make current word lowercase
    • Buffer management:
      • :ls list current buffers
      • :b <any part of filename> <tab> change to relative buffer
      • :b# change to the last buffer you used. Mostly, Ctrl-^ acts the same.
      • :bn change to the next buffer in the buffer list.
      • :bp change to the previous buffer in the buffer list.

    Blogged with Flock

    Tags:

    posted @ 2007-11-08 19:55 django 閱讀(357) | 評(píng)論 (0)編輯 收藏
     
    1. 在普通模式下,用*可以搜索當(dāng)前光標(biāo)所在的單詞.
    2. 打開(kāi)同目錄下的文件. 普通模式下,:e,然后按tab鍵,選擇要編輯的文件.
    3. 快速移動(dòng)到代碼塊的開(kāi)頭: [{. 快速移動(dòng)到代碼塊的結(jié)束: ]}
    4. gd會(huì)跳到當(dāng)前光標(biāo)下變量的聲明處
    5. 把tab轉(zhuǎn)換為空格:set expandtab,如果想輸入真正的tab,可以用Ctrl-V<Tab>
    6. 總是顯示status line: set laststatus=2
    7. 避免"Hit ENTER to continue"的提示: set shortmess=a
    8. 增加命令行的行數(shù):set cmdheight=2
    9. 顯示行數(shù): set number
    10. 增加光標(biāo)下的數(shù)字: Ctrl-A,減少光標(biāo)下的數(shù)字:Ctrl-X

    Blogged with Flock

    Tags: ,

    posted @ 2007-11-08 11:29 django 閱讀(285) | 評(píng)論 (0)編輯 收藏
     
    we use exchange and outlook as our email system in the company. Generally, it is fast and easy to use, except its search and tag functions. (Outlook2007 has done some enhancement, but gmail is more easy to use.)
    Now gmail has opened its IMAP service for free. Here is an google article to tell us how to import local emails to gmail. Following the steps in the article, you are able to move your important local emails to gmail and enjoy gmail's powerful search and tag functions.

    Blogged with Flock

    Tags:

    posted @ 2007-11-07 16:21 django 閱讀(267) | 評(píng)論 (0)編輯 收藏
     
    As the definition on the Internet, IPython is an enhanced interactive Python shell. It has a lot of attractive features over the original Python shell. I take a quick look at them, and list my favorites.
    • 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:

    posted @ 2007-11-06 16:32 django 閱讀(525) | 評(píng)論 (0)編輯 收藏
    僅列出標(biāo)題
    共12頁(yè): First 上一頁(yè) 4 5 6 7 8 9 10 11 12 下一頁(yè) 
     
    主站蜘蛛池模板: 免费下载成人电影| 亚洲精品视频久久| 好大好硬好爽免费视频| 不卡视频免费在线观看| 国产精品亚洲二区在线| 中文字幕亚洲情99在线| 亚洲精品午夜视频| 亚洲国产精品一区二区第一页| 国产小视频在线免费| 成人毛片视频免费网站观看| 99精品视频免费观看| 中文字幕手机在线免费看电影| 国产精品亚洲а∨无码播放麻豆 | 曰批免费视频播放免费| 精品国产成人亚洲午夜福利| 亚洲精品国产成人中文| 亚洲国产综合91精品麻豆| 亚洲国产精品无码成人片久久| 亚洲国产精品综合久久网络| 国产一级淫片视频免费看| 美女黄网站人色视频免费国产 | 内射干少妇亚洲69XXX| 亚洲国产精品无码专区在线观看| 国产AV无码专区亚洲AV漫画| 亚洲精品视频在线观看你懂的| 亚洲人成小说网站色| 亚洲第一区视频在线观看| 久久水蜜桃亚洲av无码精品麻豆| 亚洲Av永久无码精品三区在线| 日本一道本高清免费| 浮力影院第一页小视频国产在线观看免费| 无码国产精品一区二区免费虚拟VR| 69影院毛片免费观看视频在线 | 午夜亚洲av永久无码精品| 日本午夜免费福利视频| 日韩免费无码一区二区视频| 波多野结衣免费视频观看| 亚洲国产精品狼友中文久久久| 亚洲一本大道无码av天堂| 中文字幕精品亚洲无线码二区 | 久久久久久免费一区二区三区|