<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è) 
     
    主站蜘蛛池模板: 亚洲av永久综合在线观看尤物| 亚洲综合在线成人一区| 免费在线观影网站| 亚洲免费在线视频观看| 亚洲国产精品尤物yw在线| 一级毛片aaaaaa免费看| 亚洲AV无码片一区二区三区| 精品国产_亚洲人成在线高清| 成熟女人特级毛片www免费| 中文成人久久久久影院免费观看| 亚洲a视频在线观看| 中文字幕第一页亚洲| 毛片A级毛片免费播放| 成人黄网站片免费视频| 国产精品亚洲色图| 亚洲精品网站在线观看你懂的| 日产国产精品亚洲系列| 99久久免费国产香蕉麻豆| 两个人www免费高清视频| 亚洲狠狠婷婷综合久久蜜芽| 亚洲黄色在线观看| 亚洲综合无码精品一区二区三区| 成人毛片18女人毛片免费视频未| 免费国产成人午夜在线观看| 黄网站色视频免费观看45分钟| 亚洲国产成人综合| 亚洲va中文字幕无码久久 | 亚洲色在线无码国产精品不卡| 亚洲熟妇丰满多毛XXXX| 波多野结衣视频在线免费观看| 成年黄网站色大免费全看| 国产一区二区免费视频| 国产99精品一区二区三区免费 | 亚洲电影唐人社一区二区| 国产亚洲精品a在线观看| 卡1卡2卡3卡4卡5免费视频| 日本高清在线免费| 91成人在线免费观看| 国产午夜无码精品免费看动漫| 一级特黄录像免费播放肥| 午夜免费国产体验区免费的|