{"id":451,"date":"2013-08-21T00:45:10","date_gmt":"2013-08-21T04:45:10","guid":{"rendered":"http:\/\/zhanxw.com\/blog\/?p=451"},"modified":"2013-08-21T00:45:10","modified_gmt":"2013-08-21T04:45:10","slug":"%e7%bb%99%e4%bd%9c%e8%80%85%e7%bc%96%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/zhanxw.com\/blog\/2013\/08\/%e7%bb%99%e4%bd%9c%e8%80%85%e7%bc%96%e5%8f%b7\/","title":{"rendered":"\u7ed9\u4f5c\u8005\u7f16\u53f7"},"content":{"rendered":"<p>\u7ed9\u4f5c\u8005\u7f16\u53f7<\/p>\n<p>Author Number<\/p>\n<p><a title=\"Author Number\" href=\"http:\/\/zhanxw.com\/author\" target=\"_blank\">http:\/\/zhanxw.com\/author<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u6700\u8fd1\u5199\u4e86\u4e00\u4e2a\u7f51\u9875\uff0c\u4e3b\u8981\u89e3\u51b3\u5199\u6587\u7ae0\u7ed9\u4f5c\u8005\u7f16\u53f7\u7684\u95ee\u9898\u3002\u8fd9\u4e2a\u95ee\u9898\u600e\u4e48\u6765\u7684\u5462\uff1f\u73b0\u5728\u7684\u6587\u7ae0\u9700\u8981\u63d0\u4f9b\u4f5c\u8005\uff0c\u4f5c\u8005\u5de5\u4f5c\u5355\u4f4d\u548c\u4f5c\u8005\u7684\u8d21\u732e\uff0c\u4f46\u662f\u63d0\u4f9b\u7684\u65b9\u5f0f\u662f\u7ed9\u6bcf\u4e2a\u4f5c\u8005\u5355\u4f4d\u6309\u7167\u4f5c\u8005\u51fa\u73b0\u7684\u987a\u5e8f\u7f16\u53f7\u3002\u6bd4\u5982\u6211\u7684\u6587\u7ae0\u670979\u4e2a\u4f5c\u8005\uff0c\u73b0\u5728\u7a81\u7136\u8981\u52a0\u4e00\u4e2a\u65b0\u7684\u5408\u4f5c\u8005\uff0c\u628a\u4ed6\u62cd\u5230\u7b2c50\u4f4d\uff0c\u90a3\u4e48\u4ece\u7b2c51\u4f4d\u5230\u6700\u540e\u4e00\u4f4d\u4f5c\u8005\u7684\u7f16\u53f7\u53ef\u80fd\u90fd\u9700\u8981\u6539\u53d8\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5f88\u5bb9\u6613\u51fa\u9519\u3002\u6211\u60f3\u5199\u4e2a\u8f6f\u4ef6\u7ed9\u6240\u6709\u4eba\u7528\uff0c\u987a\u4fbf\u51d1\u4e2a\u70ed\u95f9\uff0c\u5b66\u4e60\u4e00\u4e0bjQuery + Django\uff0c\u6700\u540e\u7684\u4f5c\u54c1\u653e\u5230\u6211\u7684\u7f51\u9875(<a title=\"Author Number\" href=\"http:\/\/zhanxw.com\/author\" target=\"_blank\">link<\/a>)\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u8fd8\u5b66\u4e60\u4e86Nginx, Emacs web-mode, \u8fd9\u7bc7\u7b14\u8bb0\u4e3b\u8981\u662f\u628a\u6211\u7684\u7ecf\u9a8c\u8bb0\u5f55\u4e0b\u6765\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>1. \u5b66\u4e60Django<\/p>\n<p>Django\u662fPython\u8bed\u8a00\u5b9e\u73b0\u7684Web\u67b6\u6784\uff0c\u5b83\u6700\u5f00\u59cb\u662f\u7528\u4e8e\u5c55\u793a\u65b0\u95fb\uff08Newroom\uff09\uff0c\u56fd\u5185\u7684\u8c46\u74e3\u4e5f\u7528Django\u3002\u4f5c\u4e3aPython\u7684\u201c\u7c89\u4e1d\u201d\uff0c\u6211\u5b66\u4e00\u4e0bDjango\uff0c\u5e0c\u671b\u4ee5\u540e\u53ef\u4ee5\u628a\u6709\u7528\u7684\u5de5\u5177\u653e\u5230\u7f51\u4e0a\u3002<\/p>\n<p>\u60f3\u5165\u95e8\uff0c\u6700\u597d\u6700\u7701\u65f6\u95f4\u7684\u65b9\u6cd5\u662fDjango tutorial\uff0c\u5c31\u5728Django\u7684\u5b98\u65b9\u7f51\u9875\u3002\u8fd9\u4e2aTutorial\u4e00\u5171\u6709\u516d\u4e2a\u90e8\u5206\uff0c\u4ecb\u7ecd\u7684\u5e38\u7528Django\u7684\u529f\u80fd\uff0c\u5305\u62ec\uff1a \u6a21\u578b\uff08Model\uff09\uff0c\u6a21\u677f\uff08Template\uff09\uff0c\u89c6\u56fe\uff08View\uff09\uff0c\u9759\u6001\u6587\u4ef6\uff08Static\uff09\uff0c\u7ba1\u7406\u754c\u9762\uff08Admin\uff09\uff0c\u7f51\u5740\u5206\u53d1\uff08URL Dispatching\uff09\u7b49\u7b49\u3002\u5b66\u4e60\u4e4b\u540e\uff0c\u6211\u611f\u5230Django\u7684\u5f3a\u9879\u662f\u5229\u7528Python\u8bed\u8a00\u505a\u5230\u6765\u7b80\u5316\u6570\u636e\u5e93\u4f7f\u7528\u3002\u5bf9\u4e8e\u4e00\u4e2a\u7b80\u5355\u7684App\uff0c\u57fa\u672c\u5f00\u53d1\u7684\u6d41\u7a0b\u662f\uff1a \uff081\uff09\u8bbe\u5b9aproject \u7684settings.py \u548curls.py\uff0c\u6ce8\u518c\u65b0\u7684app \uff1b\uff082\uff09\u8bbe\u5b9aurls.py\u6765\u786e\u5b9a\u7f51\u5740\u548c\u89c6\u56fe\uff08View\uff09\u7684\u5173\u7cfb\uff1b\uff083\uff09\u7528HTML\u5f00\u53d1\u6a21\u677f\uff08\/template\/app\/XXX.html\uff09\u540c\u65f6\u5b9e\u73b0\u5404\u79cd\u9700\u8981\u7684\u89c6\u56fe\uff08views.py\uff09<\/p>\n<p>\u67b6\u8bbeDjango\uff0c\u4e00\u822c\u7b80\u6613\u4f7f\u7528uWSGI\u3002\u6211\u4f7f\u7528\u7684\u662fNginx\u5904\u7406\u9759\u6001\u9875\u9762\uff0c\u540c\u65f6\u7528uWSGI\u5904\u7406Django\u76f8\u5173\u754c\u9762\u3002\u7b80\u6613\u5148\u5728\u672c\u673a\u7528uWSGI\u8c03\u597d\u7a0b\u5e8f\uff0c\u518d\u653e\u5230\u670d\u52a1\u5668\u4e0a\u5e76\u914d\u7f6eNginx\u548cuWSGI\u3002<\/p>\n<p>Djano\u9ed8\u8ba4\u4f7f\u7528Unicode\uff0c\u800c\u6211\u4eec\u4e00\u822c\u90fd\u7528str()\uff0c\u8fd9\u662fASCII\u7f16\u7801\u3002\u4e24\u79cd\u7f16\u7801\u5bf9\u4e8e\u5b57\u7b26\u4e32\u5904\u7406\u6765\u8bb2\uff08\u5305\u62ecjoin, index\uff09\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\uff0c\u4f46\u5728print\u7684\u65f6\u5019\uff0cUnicode\u7684\u5b57\u7b26\u5e94\u8be5\u5148\u8f6c\u6210UTF-8\u5b57\u7b26\uff0c\u6bd4\u5982\uff1a print u&#8221;aaa&#8221;.encode(&#8216;UTF-8&#8217;)<\/p>\n<p>&nbsp;<\/p>\n<p>2. \u5b66\u4e60jQuery<\/p>\n<p>\u7528jQuery\u7684\u4e3b\u8981\u76ee\u7684\u662f\u7528Ajax\u6765\u66f4\u65b0\u7f51\u9875\u6570\u636e\uff0c\u8fd9\u6837\u7528\u6237\u7528\u8d77\u6765\u6709\u884c\u4e91\u6d41\u6c34\u7684\u611f\u89c9\u3002jQuery\u6709.get \u548c .post\u4e24\u4e2a\u65b9\u6cd5\uff0c\u4f7f\u7528\u8d77\u6765\u548c\u8bbf\u95ee\u7f51\u9875\u5f88\u76f8\u4f3c\u3002\u4e0d\u8fc7\u8fd9\u91cc\u9762\u6709\u51e0\u4e2a\u9677\u9631\u3002\u7b2c\u4e00\u4e2a\u662fGET\u65b9\u5f0f\u9002\u5408\u5c0f\u6570\u636e\uff0c\u5bf9\u4e8eDjango\u6765\u8bb2\uff0c\u9ed8\u8ba4\u7684\u5927\u5c0f\u662f4096\u4e2a\u5b57\u7b26\uff0c\u5927\u4e00\u70b9\u7684\u6570\u636e\u5e94\u8be5\u7528POST\uff1b\u7b2c\u4e8c\u4e2a\u9677\u9631\u5c31\u662fPOST\uff0c\u4e3a\u4e86\u5b89\u5168\uff08CSRF: cross-site request forgery\uff09\uff0cDjango\u8981\u6c42POST\u7684\u6570\u636e\u5fc5\u987b\u6709csrftoken\uff0c\u4e00\u822c\u7684HTML\u8868\u683cForm\u5fc5\u987b\u6709csrf\u7684\u6807\u8bb0\u624d\u4f1a\u88abDjango\u63a5\u6536\u3002<\/p>\n<p>\u4e3a\u4e86\u8c03\u8bd5Ajax\u7684\u8f93\u5165\u8f93\u51fa\uff0c\u7b80\u6613\u7528Firefox\u4e0b\u7684FireBug\u6216\u8005\u6700\u65b0\u7248\u672c\u7684Firefox\uff0c\u5b83\u4eec\u90fd\u53ef\u4ee5\u663e\u793aAjax\u8bf7\u6c42\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c\u3002\u6700\u65b0\u7248\u672c\u7684Firefox\u8fd8\u53ef\u4ee5\u7ed9Javascript\u8bbe\u7f6e\u65ad\u70b9\uff0c\u8fd9\u5c31\u66f4\u52a0\u964d\u4f4e\u4e86\u8c03\u8bd5\u7684\u96be\u5ea6\u3002<\/p>\n<p>jQuery\u7684\u529f\u80fd\u5f88\u591a\uff0c\u8fd9\u4e2a\u7f51\u9875\u628ajQuery 1.9\u4ee5\u53ca\u4e4b\u524d\u7248\u672c\u7684\u529f\u80fd\u7528\u4e0d\u540c\u989c\u8272\u533a\u5206\u51fa\u6765\uff0c\u5f88\u65b9\u4fbf\u67e5\u8be2\uff08<a title=\"jQuery Reference\" href=\"http:\/\/oscarotero.com\/jquery\/\" target=\"_blank\">link<\/a>\uff09\u3002<\/p>\n<p>\u5728\u8fd9\u4e2a\u7f51\u9875\u4e2d\uff0c\u6211\u8fd8\u7528\u4e86<a title=\"handsontable\" href=\"http:\/\/handsontable.com\/\" target=\"_blank\">handsontable<\/a>\uff0c\u8fd9\u662f\u4e00\u4e2a\u5728jQuery\u7684\u57fa\u7840\u4e0a\u5f00\u53d1\u7684\u5b9e\u7528\u7684javascript spreadsheet\uff0c\u8bed\u6cd5\u7b80\u5355\uff0c\u4f7f\u7528\u65b9\u4fbf\u3002<\/p>\n<p>3. \u4e00\u70b9Nginx\u7ecf\u9a8c<\/p>\n<p>\u5bf9Nginx\u6765\u8bb2\uff0c\u6211\u4eec\u7684\u914d\u7f6e\u662f\u7528location\u8bed\u53e5\u6765\u628a\u7279\u5b9a\u7684\u7f51\u5740\u4f20\u7ed9uWSGI\u8fdb\u7a0b\u3002\u6ce8\u610fNginx\u8bbe\u7f6e\u91cc\u5982\u679c\u6709\u591a\u4e2alocation\u8bed\u53e5\uff0cNginx\u5e76\u4e0d\u4e00\u5b9a\u9009\u62e9\u6700\u5148\u5339\u914d\u7684\u7f51\u5740\uff0c\u800c\u662f\u9009\u62e9\u6700\u957f\u7684\u7f51\u5740\u3002\u6bd4\u5982\uff1a<\/p>\n<p>location ~* \/author\/static\/.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {<br \/>\nroot \/var\/django\/zhanxw\/; # STATIC_ROOT<br \/>\nexpires 30d;<br \/>\n}<\/p>\n<p>location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {<br \/>\naccess_log\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 off;<br \/>\nexpires\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 30d;<br \/>\nroot \/var\/www;<br \/>\n}<\/p>\n<p>\u5982\u679c\u7b2c\u4e00\u4e2alocation\u5199\u6210\uff1a &#8220;location \/author\/static&#8221;\uff0c\u90a3\u4e48.jpg\u4e4b\u7c7b\u7684\u6587\u4ef6\u4f1a\u88ab\u7b2c\u4e8c\u4e2alocation\u5904\u7406\uff0c\u8fd9\u5c31\u4e0d\u662fDjango static\u6587\u4ef6\u7684\u6b63\u786e\u5904\u7406\u65b9\u5f0f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>4. \u4e00\u70b9Emacs web-mode\u7ecf\u9a8c<\/p>\n<p>\u7528Emacs\u5199Django\u7684\u6a21\u677fHTML\uff0c\u6700\u597d\u7528\u7684\u4e0d\u662fdjango-html-mode\uff0c\u800c\u662f<a title=\"web-mode\" href=\"http:\/\/web-mode.org\/\" target=\"_blank\">web-mode<\/a>\u3002\u53ea\u6709\u8fd9\u4e2amode\u53ef\u4ee5\u8bc6\u522b \u201c{% static &#8216;polls\/index.html&#8217; %}\u201d\u8fd9\u6837\u7684\u8bb0\u53f7\uff0c\u5e76\u6b63\u786e\u7f29\u8fdb\u3002<\/p>\n<p>\u6b64\u5916web-mode\u53ef\u4ee5\u81ea\u52a8\u8865\u5168HTML tab\uff0c\u6bd4\u5982\u4f60\u5728&lt;p&gt;\u540e\u9762\u6253&lt;\/\uff0cweb-mode\u4f1a\u5e2e\u4f60\u8865\u5168&lt;\/p&gt;\u3002\u8fd8\u53ef\u4ee5\u7528C-c C-e b \u548cC-c C-e e\u8df3\u5230\u4e00\u5bf9tag\u7684\u6700\u524d\u9762\uff08beginning\uff09\u548c\u6700\u540e\u9762\uff08end\uff09\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>5. \u4e00\u822c\u6027\u7ecf\u9a8c<\/p>\n<p>\u6700\u5f00\u59cb\u8bbe\u8ba1\u5e94\u8be5\u4ee5\u6700\u5c11\u529f\u80fd\uff0c\u6700\u5c0f\u5b9e\u73b0\u4e3a\u597d\uff0c\u4e0d\u8981\u4e00\u4e0b\u5b50\u628a\u754c\u9762\u8bbe\u8ba1\u590d\u6742\u3002\u53ef\u4ee5\u60f3\u51e0\u4e2a\u7528\u4f8b\uff08Use Case\uff09\uff0c\u4fdd\u8bc1\u6700\u57fa\u672c\u6700\u91cd\u8981\u7684\u529f\u80fd\uff0c\u5176\u4ed6\u529f\u80fd\u5e94\u8be5\u8d8a\u5c11\u8d8a\u597d\u3002<\/p>\n<p>\u7f51\u9875\u7684\u5e03\u5c40\u5e94\u8be5\u5c11\u7528&lt;br\/&gt;\u8fd9\u79cd\u786c\u56de\u8f66\u3002\u5728\u6709Bootstrap\u7684\u60c5\u51b5\u4e0b\uff0c\u5b8c\u5168\u53ef\u4ee5\u7528&lt;div&gt;\u548c&lt;p&gt;\u6765\u7528\u66f4\u5c11\u7684HTML tag\u6765\u5b9e\u73b0\u66f4\u81ea\u7136\u3001\u81ea\u52a8\u7684\u5e03\u5c40\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u4f5c\u8005\u7f16\u53f7 Author Number http:\/\/zhanxw.com\/author &nbsp; \u6700\u8fd1\u5199\u4e86\u4e00\u4e2a\u7f51\u9875\uff0c\u4e3b\u8981\u89e3\u51b3\u5199\u6587\u7ae0\u7ed9\u4f5c\u8005\u7f16\u53f7\u7684\u95ee\u9898\u3002\u8fd9\u4e2a\u95ee\u9898\u600e\u4e48\u6765\u7684\u5462\uff1f\u73b0\u5728\u7684\u6587\u7ae0\u9700\u8981\u63d0\u4f9b\u4f5c\u8005\uff0c\u4f5c\u8005\u5de5\u4f5c\u5355\u4f4d\u548c\u4f5c\u8005\u7684\u8d21\u732e\uff0c\u4f46\u662f\u63d0\u4f9b\u7684\u65b9\u5f0f\u662f\u7ed9\u6bcf\u4e2a\u4f5c\u8005\u5355\u4f4d\u6309\u7167\u4f5c\u8005\u51fa\u73b0\u7684\u987a\u5e8f\u7f16\u53f7\u3002\u6bd4\u5982\u6211\u7684\u6587\u7ae0\u670979\u4e2a\u4f5c\u8005\uff0c\u73b0\u5728\u7a81\u7136\u8981\u52a0\u4e00\u4e2a\u65b0\u7684\u5408\u4f5c\u8005\uff0c\u628a\u4ed6\u62cd\u5230\u7b2c50\u4f4d\uff0c\u90a3\u4e48\u4ece\u7b2c51\u4f4d\u5230\u6700\u540e\u4e00\u4f4d\u4f5c\u8005\u7684\u7f16\u53f7\u53ef\u80fd\u90fd\u9700\u8981\u6539\u53d8\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5f88\u5bb9\u6613\u51fa\u9519\u3002\u6211\u60f3\u5199\u4e2a\u8f6f\u4ef6\u7ed9\u6240\u6709\u4eba\u7528\uff0c\u987a\u4fbf\u51d1\u4e2a\u70ed\u95f9\uff0c\u5b66\u4e60\u4e00\u4e0bjQuery + Django\uff0c\u6700\u540e\u7684\u4f5c\u54c1\u653e\u5230\u6211\u7684\u7f51\u9875(link)\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u8fd8\u5b66\u4e60\u4e86Nginx, Emacs web-mode, \u8fd9\u7bc7\u7b14\u8bb0\u4e3b\u8981\u662f\u628a\u6211\u7684\u7ecf\u9a8c\u8bb0\u5f55\u4e0b\u6765\u3002 &nbsp; 1. \u5b66\u4e60Django Django\u662fPython\u8bed\u8a00\u5b9e\u73b0\u7684Web\u67b6\u6784\uff0c\u5b83\u6700\u5f00\u59cb\u662f\u7528\u4e8e\u5c55\u793a\u65b0\u95fb\uff08Newroom\uff09\uff0c\u56fd\u5185\u7684\u8c46\u74e3\u4e5f\u7528Django\u3002\u4f5c\u4e3aPython\u7684\u201c\u7c89\u4e1d\u201d\uff0c\u6211\u5b66\u4e00\u4e0bDjango\uff0c\u5e0c\u671b\u4ee5\u540e\u53ef\u4ee5\u628a\u6709\u7528\u7684\u5de5\u5177\u653e\u5230\u7f51\u4e0a\u3002 \u60f3\u5165\u95e8\uff0c\u6700\u597d\u6700\u7701\u65f6\u95f4\u7684\u65b9\u6cd5\u662fDjango tutorial\uff0c\u5c31\u5728Django\u7684\u5b98\u65b9\u7f51\u9875\u3002\u8fd9\u4e2aTutorial\u4e00\u5171\u6709\u516d\u4e2a\u90e8\u5206\uff0c\u4ecb\u7ecd\u7684\u5e38\u7528Django\u7684\u529f\u80fd\uff0c\u5305\u62ec\uff1a \u6a21\u578b\uff08Model\uff09\uff0c\u6a21\u677f\uff08Template\uff09\uff0c\u89c6\u56fe\uff08View\uff09\uff0c\u9759\u6001\u6587\u4ef6\uff08Static\uff09\uff0c\u7ba1\u7406\u754c\u9762\uff08Admin\uff09\uff0c\u7f51\u5740\u5206\u53d1\uff08URL Dispatching\uff09\u7b49\u7b49\u3002\u5b66\u4e60\u4e4b\u540e\uff0c\u6211\u611f\u5230Django\u7684\u5f3a\u9879\u662f\u5229\u7528Python\u8bed\u8a00\u505a\u5230\u6765\u7b80\u5316\u6570\u636e\u5e93\u4f7f\u7528\u3002\u5bf9\u4e8e\u4e00\u4e2a\u7b80\u5355\u7684App\uff0c\u57fa\u672c\u5f00\u53d1\u7684\u6d41\u7a0b\u662f\uff1a \uff081\uff09\u8bbe\u5b9aproject \u7684settings.py \u548curls.py\uff0c\u6ce8\u518c\u65b0\u7684app \uff1b\uff082\uff09\u8bbe\u5b9aurls.py\u6765\u786e\u5b9a\u7f51\u5740\u548c\u89c6\u56fe\uff08View\uff09\u7684\u5173\u7cfb\uff1b\uff083\uff09\u7528HTML\u5f00\u53d1\u6a21\u677f\uff08\/template\/app\/XXX.html\uff09\u540c\u65f6\u5b9e\u73b0\u5404\u79cd\u9700\u8981\u7684\u89c6\u56fe\uff08views.py\uff09 \u67b6\u8bbeDjango\uff0c\u4e00\u822c\u7b80\u6613\u4f7f\u7528uWSGI\u3002\u6211\u4f7f\u7528\u7684\u662fNginx\u5904\u7406\u9759\u6001\u9875\u9762\uff0c\u540c\u65f6\u7528uWSGI\u5904\u7406Django\u76f8\u5173\u754c\u9762\u3002\u7b80\u6613\u5148\u5728\u672c\u673a\u7528uWSGI\u8c03\u597d\u7a0b\u5e8f\uff0c\u518d\u653e\u5230\u670d\u52a1\u5668\u4e0a\u5e76\u914d\u7f6eNginx\u548cuWSGI\u3002 Djano\u9ed8\u8ba4\u4f7f\u7528Unicode\uff0c\u800c\u6211\u4eec\u4e00\u822c\u90fd\u7528str()\uff0c\u8fd9\u662fASCII\u7f16\u7801\u3002\u4e24\u79cd\u7f16\u7801\u5bf9\u4e8e\u5b57\u7b26\u4e32\u5904\u7406\u6765\u8bb2\uff08\u5305\u62ecjoin, index\uff09\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\uff0c\u4f46\u5728print\u7684\u65f6\u5019\uff0cUnicode\u7684\u5b57\u7b26\u5e94\u8be5\u5148\u8f6c\u6210UTF-8\u5b57\u7b26\uff0c\u6bd4\u5982\uff1a print u&#8221;aaa&#8221;.encode(&#8216;UTF-8&#8217;) &nbsp; 2. \u5b66\u4e60jQuery \u7528jQuery\u7684\u4e3b\u8981\u76ee\u7684\u662f\u7528Ajax\u6765\u66f4\u65b0\u7f51\u9875\u6570\u636e\uff0c\u8fd9\u6837\u7528\u6237\u7528\u8d77\u6765\u6709\u884c\u4e91\u6d41\u6c34\u7684\u611f\u89c9\u3002jQuery\u6709.get \u548c .post\u4e24\u4e2a\u65b9\u6cd5\uff0c\u4f7f\u7528\u8d77\u6765\u548c\u8bbf\u95ee\u7f51\u9875\u5f88\u76f8\u4f3c\u3002\u4e0d\u8fc7\u8fd9\u91cc\u9762\u6709\u51e0\u4e2a\u9677\u9631\u3002\u7b2c\u4e00\u4e2a\u662fGET\u65b9\u5f0f\u9002\u5408\u5c0f\u6570\u636e\uff0c\u5bf9\u4e8eDjango\u6765\u8bb2\uff0c\u9ed8\u8ba4\u7684\u5927\u5c0f\u662f4096\u4e2a\u5b57\u7b26\uff0c\u5927\u4e00\u70b9\u7684\u6570\u636e\u5e94\u8be5\u7528POST\uff1b\u7b2c\u4e8c\u4e2a\u9677\u9631\u5c31\u662fPOST\uff0c\u4e3a\u4e86\u5b89\u5168\uff08CSRF: cross-site request forgery\uff09\uff0cDjango\u8981\u6c42POST\u7684\u6570\u636e\u5fc5\u987b\u6709csrftoken\uff0c\u4e00\u822c\u7684HTML\u8868\u683cForm\u5fc5\u987b\u6709csrf\u7684\u6807\u8bb0\u624d\u4f1a\u88abDjango\u63a5\u6536\u3002 \u4e3a\u4e86\u8c03\u8bd5Ajax\u7684\u8f93\u5165\u8f93\u51fa\uff0c\u7b80\u6613\u7528Firefox\u4e0b\u7684FireBug\u6216\u8005\u6700\u65b0\u7248\u672c\u7684Firefox\uff0c\u5b83\u4eec\u90fd\u53ef\u4ee5\u663e\u793aAjax\u8bf7\u6c42\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c\u3002\u6700\u65b0\u7248\u672c\u7684Firefox\u8fd8\u53ef\u4ee5\u7ed9Javascript\u8bbe\u7f6e\u65ad\u70b9\uff0c\u8fd9\u5c31\u66f4\u52a0\u964d\u4f4e\u4e86\u8c03\u8bd5\u7684\u96be\u5ea6\u3002 jQuery\u7684\u529f\u80fd\u5f88\u591a\uff0c\u8fd9\u4e2a\u7f51\u9875\u628ajQuery 1.9\u4ee5\u53ca\u4e4b\u524d\u7248\u672c\u7684\u529f\u80fd\u7528\u4e0d\u540c\u989c\u8272\u533a\u5206\u51fa\u6765\uff0c\u5f88\u65b9\u4fbf\u67e5\u8be2\uff08link\uff09\u3002 \u5728\u8fd9\u4e2a\u7f51\u9875\u4e2d\uff0c\u6211\u8fd8\u7528\u4e86handsontable\uff0c\u8fd9\u662f\u4e00\u4e2a\u5728jQuery\u7684\u57fa\u7840\u4e0a\u5f00\u53d1\u7684\u5b9e\u7528\u7684javascript spreadsheet\uff0c\u8bed\u6cd5\u7b80\u5355\uff0c\u4f7f\u7528\u65b9\u4fbf\u3002 3. \u4e00\u70b9Nginx\u7ecf\u9a8c \u5bf9Nginx\u6765\u8bb2\uff0c\u6211\u4eec\u7684\u914d\u7f6e\u662f\u7528location\u8bed\u53e5\u6765\u628a\u7279\u5b9a\u7684\u7f51\u5740\u4f20\u7ed9uWSGI\u8fdb\u7a0b\u3002\u6ce8\u610fNginx\u8bbe\u7f6e\u91cc\u5982\u679c\u6709\u591a\u4e2alocation\u8bed\u53e5\uff0cNginx\u5e76\u4e0d\u4e00\u5b9a\u9009\u62e9\u6700\u5148\u5339\u914d\u7684\u7f51\u5740\uff0c\u800c\u662f\u9009\u62e9\u6700\u957f\u7684\u7f51\u5740\u3002\u6bd4\u5982\uff1a location ~* \/author\/static\/.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { root \/var\/django\/zhanxw\/; # STATIC_ROOT expires 30d; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,11],"tags":[113,33,114,22,53],"class_list":["post-451","post","type-post","status-publish","format-standard","hentry","category-code","category-sysadmin","tag-django","tag-emacs","tag-jquery","tag-nginx","tag-python"],"_links":{"self":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/comments?post=451"}],"version-history":[{"count":0,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/451\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/media?parent=451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/categories?post=451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/tags?post=451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}