<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8456343801196608451</id><updated>2024-10-09T10:46:55.624+09:00</updated><category term="python"/><category term="django"/><category term="インストール"/><category term="Ubuntu"/><category term="NetBeans"/><category term="php"/><category term="apache2"/><category term="java"/><category term="mac"/><category term="mysql"/><category term="node.js"/><category term="スクレイピング"/><category term="django 1.3.1"/><category term="eclipse"/><category term="mamp"/><category term="symfony"/><category term="エラー"/><category term="UI"/><category term="Web"/><category term="responsive"/><category term="symfony2"/><category term="プラグイン"/><category term="日記"/><category term="設定"/><category term="Adobe"/><category term="G Data"/><category term="GAE"/><category term="McAfee"/><category term="Microsoft"/><category term="UML"/><category term="VMware"/><category term="Webサイト"/><category term="ajax"/><category term="asp.net"/><category term="blogger"/><category term="c#"/><category term="chai"/><category term="emacs"/><category term="flot"/><category term="gm"/><category term="iPad"/><category term="jquery"/><category term="jsdom"/><category term="mocha"/><category term="npm"/><category term="opencv"/><category term="phpMyAdmin"/><category term="port"/><category term="pytho"/><category term="safari"/><category term="spring mvc"/><category term="web design"/><category term="wordpress"/><category term="xampp"/><category term="xcode"/><category term="アドオン"/><category term="ウイルス"/><category term="クレジットカード"/><category term="グラフ"/><category term="セキュリティ"/><category term="ソフトウェア"/><category term="ツール"/><category term="テスト"/><category term="ビザ"/><category term="プログラミング"/><category term="出国"/><category term="手続き"/><category term="携帯"/><category term="米国生活"/><category term="評価"/><category term="銀行"/><title type='text'>オトなか</title><subtitle type='html'>シリコンバレーへ移住する生活が始まりました。日本国外で生活を始めるのは初めてなので、色々と書き留めておきたいと思います。</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>51</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-2805897072653376837</id><published>2016-08-15T15:18:00.002+09:00</published><updated>2016-08-15T15:18:47.633+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="クレジットカード"/><category scheme="http://www.blogger.com/atom/ns#" term="ビザ"/><category scheme="http://www.blogger.com/atom/ns#" term="出国"/><category scheme="http://www.blogger.com/atom/ns#" term="手続き"/><category scheme="http://www.blogger.com/atom/ns#" term="携帯"/><category scheme="http://www.blogger.com/atom/ns#" term="米国生活"/><category scheme="http://www.blogger.com/atom/ns#" term="銀行"/><title type='text'>米国への移住生活の始まり</title><content type='html'>日本を出てから３日が経ちました。&lt;br /&gt;
今回、勤めている会社で、米国の拠点に海外駐在するチャンスを得ることができました。&lt;br /&gt;
駐在が決まってから、出国するまでも手続きなどやらなければならないことが多く大変な毎日を過ごしていましたが、出国後も毎日が新しいこととの戦いです。&lt;br /&gt;
&lt;br /&gt;
インターネットからも情報を得ているのですが、情報が古かったりして、「あれ？」となることも多々あります。時間が経てば、手続きなどの方法も変わるため、仕方がないですが・・・。直近に同じ手続きをする人がいればと思い、私の場合の経験を書き残していこうと思います。&lt;br /&gt;
&lt;br /&gt;
ちなみに、私の移住先は米国西海岸にあるシリコンバレー地域です。シリコンバレーという地名があるわけではなく、AppleやGoogleなど昔から多くのIT企業が集まる地域を指した通称のようなものです。&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
出国までに行った手続きについて&lt;/h3&gt;
ビザの取得はもちろんですが、出国までにも様々な手続きを行いました。例えば、米国で利用する銀行の口座を開設やクレジットカードの作成など、現地で生活を始めるために必要な手続きもあれば、米国用の携帯電話の契約や日本の携帯電話を解約しないで電話番号を帰国後にも使えるようにする手続きなど、やっておくと後々役立つような手続きも紹介します。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
ビザ&lt;/h4&gt;
&lt;br /&gt;
私の場合、L1ビザと呼ばれるビザを取得しました。このビザは、米国へ駐在する人が取得するビザの一種です。このビザは米国現地の法人でマネージメントをする人や、専門性の高い能力を備えた人に発給されるビザであるため、基本的には会社が申請手続きを進めていくことになります。&lt;br /&gt;
申請者本人が準備する書類としては、証明写真（電子・プリント）、英語版の大学の卒業証明書、家族を帯同させる場合、戸籍謄本（全部証明）がくらいでしょうか。&lt;br /&gt;
また、ビザ申請に必要な個人情報はDS-160と呼ばれるフォームへWebで登録します。会社が登録する場合は、会社への個人情報の提供が必要になります。&lt;br /&gt;
会社が準備する書類は、申請者本人の職歴、および、なぜ現地へその人を駐在させて働かせないといけないのかを説明するレター、会社リスト、Form I-129S、Form G-28と多種にわたります。&lt;br /&gt;
&lt;br /&gt;
これらの書類を揃えた上で、米国大使館へ面接の予約を行ないます。&lt;br /&gt;
米国大使館では、「手荷物検査-&amp;gt;受付-&amp;gt;書類提出-&amp;gt;保証金（500ドル）の支払い-&amp;gt;指紋採取-&amp;gt;面接」という順番で面接が進みます。混雑状況によりますが、受付までに１時間、面接が終わるまでにさらに２時間と合計３時間かかる人もいるようです。私の場合、朝８時に行ったため、まだ混雑しておらず、待つことなく受付を済ませることができました。さらに、受付後も１時間足らずで手続きを終えることができました。&lt;br /&gt;
私の場合、面接は、勤務先の確認と業務内容を聞かれたくらいで数分で終わりました。ここで、入社年度が５年未満と浅い場合、なぜ現地で人を雇うのではなく人を駐在させなければを説明させられるそうです。&lt;br /&gt;
面接の最後に、その場でビザが発給されるかどうかがわかるので、発給されない場合、なぜダメだったのかを聞いておけば、理由によっては再申請で発給される可能性は高くなります。&lt;br /&gt;
米国大使館へ行く際に気をつけることは、鞄がリュックではダメなこと、電子機器や記録媒体の持込が禁止であることです。できるだけ荷物は駅のコインロッカーに預けるようにして、提出する書類と、待ち時間を潰すための文庫本だけにした方が無難だと思います。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
銀行口座開設&lt;/h4&gt;
&lt;br /&gt;
私の場合、ユニオンバンクとプレスティア（シティバンクATMを利用可能）の口座を開設しました。現在、日本でこれらの口座を作る場合、ユニオンバンクは東京三菱UFJ銀行が、プレスティアはSMBC信託銀行が窓口となるため、以前に比べてとても作りやすくなったんだと思います。&lt;br /&gt;
プレスティアの場合、&lt;a href=&quot;http://www.smbctb.co.jp/banking/index.html&quot; target=&quot;_blank&quot;&gt;Webサイト&lt;/a&gt;に必要事項を記入し、パスポートなどの身分証明書の情報を添付すると２週間ほどで日本の自宅にカードが届きました。&lt;br /&gt;
ユニオンバンクの場合、&lt;a href=&quot;http://www.bk.mufg.jp/tsukau/kaigai/kouza/cali/index.html&quot; target=&quot;_blank&quot;&gt;Webサイト&lt;/a&gt;で資料請求し、必要事項を記入の上、返送するとこちらも２週間ほどでカードが届きました。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
クレジットカード契約&lt;/h4&gt;
&lt;br /&gt;
米国のクレジットカードを作成する場合、クレジットのヒストリーがないと作成が困難となります。そこで日本から米国へ移住する人がよく作成するクレジットカードは&lt;a href=&quot;http://www.anacardusa.com/&quot; target=&quot;_blank&quot;&gt;ANAカード&lt;/a&gt;か&lt;a href=&quot;http://www.jalusacard.com/jp/&quot; target=&quot;_blank&quot;&gt;JALカード&lt;/a&gt;です。&lt;br /&gt;
これらのカードは出国前から申し込みが可能で、日本のヒストリーも参考にされるため、審査が短期間で、かつ、承認を受けやすいカードとなります。私の場合、年会費の安いJALカードだけを作成しました。&lt;br /&gt;
手続き方法は、Webサイトで必要な情報を記入すると、電話をかけるようにという旨のメールが数日後に届きます。そして、その番号にかけると、本人確認が行われます。さらに必要な添付書類のコピー（パスポートとビザのコピー）をWebサイトへアップロードすると、審査が開始されます。審査開始時と審査結果が出た際に登録したメールアドレスにFirst Bankcardというところからメールが届きます。（JALからではなかったので、最初はスパムメールかと思いました・・・）&lt;br /&gt;
あとは、入国後に登録した住所へカードが届く予定です。&lt;br /&gt;
まだ、入国間もないので、私の手元には届いていませんが・・・。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
携帯電話契約&lt;/h4&gt;
&lt;br /&gt;
米国に入国してから携帯電話を契約する場合、ソーシャル・セキュリティ・ナンバーやクレジットカードが必要となります。そのため、早くても１か月程度かかる可能性があるため、私の場合、日本から現地の電話番号を契約できる&lt;a href=&quot;https://www.kddimobilesim.com/pageControl.php?page=index&quot; target=&quot;_blank&quot;&gt;KDDI mobile x H2O&lt;/a&gt;を採用しました。私が申し込みをしてから、まだ１か月も経っていませんが、申し込み方法が変わっているようです。私の場合はFAXでしたが、今はWebから申し込みするようになっています。。。</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/2805897072653376837/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/2805897072653376837' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/2805897072653376837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/2805897072653376837'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2016/08/blog-post.html' title='米国への移住生活の始まり'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-8645357397342931814</id><published>2014-05-10T22:52:00.000+09:00</published><updated>2014-05-10T22:52:26.391+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gm"/><category scheme="http://www.blogger.com/atom/ns#" term="node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="エラー"/><title type='text'>node.jsのgmで画像情報を取得しようとした時のエラー</title><content type='html'>node.jsのgraphicsmagick用ライブラリgmで画像の縦横の長さを取得しようとしたときにエラーが発生&lt;br /&gt;
&lt;br /&gt;
エラー内容：&lt;br /&gt;
&lt;pre&gt;{ [Error: spawn ENOENT] code: &#39;ENOENT&#39;, errno: &#39;ENOENT&#39;, syscall: &#39;spawn&#39; }
&lt;/pre&gt;
&lt;br /&gt;
原因：&lt;br /&gt;
GraphicsMagickでImageMagickをサブクラスとして利用しており、ImageMagickが利用できない&lt;br /&gt;
&lt;br /&gt;
対応方法：&lt;br /&gt;
ImageMagickを読み込ませる（ImageMagickがインストールされていない時はインストールする）&lt;br /&gt;
&lt;pre&gt;var gm = require(&#39;gm&#39;); -&amp;gt; var gm = require(&#39;gm&#39;).subClass({ imageMagick: true });
&lt;/pre&gt;
&lt;br /&gt;
参考サイト：&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&quot;question-hyperlink&quot; href=&quot;http://stackoverflow.com/questions/16222116/error-spawn-enoent-while-using-gm-in-node&quot; style=&quot;background-color: transparent; border: 0px; color: black; cursor: pointer; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Error: spawn ENOENT while using GM in node&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://qiita.com/tototoshi/items/801095251720cb5be623&quot;&gt;Mac に PHP + ImageMagick をインストールする&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/8645357397342931814/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/8645357397342931814' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/8645357397342931814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/8645357397342931814'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2014/05/nodejsgm.html' title='node.jsのgmで画像情報を取得しようとした時のエラー'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-8194092931213241746</id><published>2014-04-21T23:00:00.002+09:00</published><updated>2014-04-21T23:04:40.323+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="chai"/><category scheme="http://www.blogger.com/atom/ns#" term="mocha"/><category scheme="http://www.blogger.com/atom/ns#" term="node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="テスト"/><title type='text'>mocha/chaiで配列を比較するとき</title><content type='html'>Node.jsのmochaと言うテストフレームワークでテストを実行し、chaiでassertしようとしたときに、うまくassertされない問題が発生した。こんな感じで。&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
describe(&#39;&#39;, function(){&lt;br /&gt;
&amp;nbsp; describe(&#39;&#39;, function(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; it(&#39;&#39;, function(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; [].should.equal([]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; });&lt;br /&gt;
&amp;nbsp; });&lt;br /&gt;
});&lt;/blockquote&gt;
これはequalが配列を１つのオブジェクトとして比較するため、配列内の１つずつのデータを比較しているわけではないために発生しているらしい。&lt;br /&gt;
&quot;equal&quot;を&quot;eql&quot;に書き換えることで、正しくassertされるようになった。&lt;br /&gt;
&lt;br /&gt;
ref:&amp;nbsp;&lt;a href=&quot;http://stackoverflow.com/questions/17526805/chai-test-array-equality-doesnt-work-as-expected&quot;&gt;http://stackoverflow.com/questions/17526805/chai-test-array-equality-doesnt-work-as-expected&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/8194092931213241746/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/8194092931213241746' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/8194092931213241746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/8194092931213241746'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2014/04/mochachai.html' title='mocha/chaiで配列を比較するとき'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-9180535149043872979</id><published>2012-09-02T23:18:00.000+09:00</published><updated>2012-09-02T23:18:00.582+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jsdom"/><category scheme="http://www.blogger.com/atom/ns#" term="node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="npm"/><category scheme="http://www.blogger.com/atom/ns#" term="pytho"/><title type='text'>macでjsdomがインストールできなかった</title><content type='html'>macのnode.js v0.8.8でnpm v1.5.9を使ってjsdomをインストール使用としたら、contentifyというライブラリのmakeに失敗してしまった&lt;br /&gt;
&lt;br /&gt;
原因は、pythonのバージョンが古かったため？？&lt;br /&gt;
よくわからないが、python v2.5.3をmac用のpythonインストーラを使ってv2.7.3にアップグレードしたら問題なくmakeできるようになった</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/9180535149043872979/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/9180535149043872979' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/9180535149043872979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/9180535149043872979'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2012/09/macjsdom.html' title='macでjsdomがインストールできなかった'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-5594117077944055296</id><published>2012-08-31T00:09:00.002+09:00</published><updated>2012-08-31T00:09:50.667+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mac"/><category scheme="http://www.blogger.com/atom/ns#" term="node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="xcode"/><title type='text'>macでmakeを使えるようにする方法</title><content type='html'>node.jsでnpmコマンドを使って、モジュールをインストールしようとしたときに、makeがないと怒られたので、macでmakeを使えるようにする手順をメモ&lt;br /&gt;
&lt;br /&gt;
１．XcodeをAppStoreからインストール&lt;br /&gt;
２．AppleのMac Dev Centerへアクセス（ログインが必要）&lt;br /&gt;
３．DownloadsのAdditional Downloadsにある「View all downloads」を選択&lt;br /&gt;
４．Command Line Tools for Xcodeをダウンロードしてインストール&lt;br /&gt;
&lt;br /&gt;
以上で、makeができるようになった。。&lt;br /&gt;
&lt;br /&gt;
XcodeをDev Centerからダウンロードしてインストールすると、Xcodeのpreferencesからインストールできるらしい。。。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/5594117077944055296/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/5594117077944055296' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/5594117077944055296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/5594117077944055296'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2012/08/macmake.html' title='macでmakeを使えるようにする方法'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-6601259521800462013</id><published>2012-08-04T08:08:00.000+09:00</published><updated>2012-08-04T08:08:01.069+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="blogger"/><category scheme="http://www.blogger.com/atom/ns#" term="responsive"/><category scheme="http://www.blogger.com/atom/ns#" term="safari"/><title type='text'>bloggerのモバイルテンプレート</title><content type='html'>bloggerのモバイルテンプレート機能がレスポンシブ・デザインに合うかを調査&lt;br /&gt;
公式な情報はうまく見つけられなかったが、どうもブラウザのユーザ・エージェントでPC/モバイルのどちらのテンプレートを利用するかを決めているよう&lt;br /&gt;
&lt;br /&gt;
Safariのデフォルトのユーザ・エージェントでアクセスした場合、&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBwERKICJ0SY5PBQCba-Vu2NfQfXrrVkyhSjo0_JX2vbkAp2lulzYrKd_H4Jgm2dXxKOtWq0gYeeLHi2aG1jY1pHia76JlTkcnVyWlQtNnsD_1YCkS_I28v2cAniUnppDMX_R6uMnWEMOm/s1600/blogger-pc-agent.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBwERKICJ0SY5PBQCba-Vu2NfQfXrrVkyhSjo0_JX2vbkAp2lulzYrKd_H4Jgm2dXxKOtWq0gYeeLHi2aG1jY1pHia76JlTkcnVyWlQtNnsD_1YCkS_I28v2cAniUnppDMX_R6uMnWEMOm/s320/blogger-pc-agent.png&quot; width=&quot;176&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Safariのユーザ・エージェントを「Safari iOS 5.1 - iPhone」に変更した場合、&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL1P-m7w1a1WL_LmvMCNAkb-x3kIRWAYGWNIvquZmPF62ctFslYwJKzPItUYwehhgH1h9_1sWIn6AhBUSSmsZNOLW6Fp_ohoMY5VGZ-Mb9V98l17-a0x6YJCHUL3yvtUrPiAT7RhR_ukwl/s1600/blogger-mobile-agent.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL1P-m7w1a1WL_LmvMCNAkb-x3kIRWAYGWNIvquZmPF62ctFslYwJKzPItUYwehhgH1h9_1sWIn6AhBUSSmsZNOLW6Fp_ohoMY5VGZ-Mb9V98l17-a0x6YJCHUL3yvtUrPiAT7RhR_ukwl/s320/blogger-mobile-agent.png&quot; width=&quot;176&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
モバイルテンプレートを適用する場合は、URLに「?m=1」という文字列が自動的に追加された。また、URLに「?m=1」をつけたままSafariのデフォルトのユーザ・エージェントに切り替えても、モバイルテンプレートが適用された。iPadのユーザ・エージェントでは、モバイルテンプレートは適用されず、PCのテンプレートが適用された。&lt;br /&gt;
&lt;br /&gt;
結論としては、表示画面の幅に応じて、デザインを切り替えるレスポンシブ・デザインでは、ユーザ・エージェントによってテンプレートを切り替える方法は適切ではない。&lt;br /&gt;
そのため、今回、モバイルテンプレート機能はオフにした。&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Safariでユーザ・エージェントを切り替える方法：&lt;/h4&gt;
・「開発」メニュー &amp;gt; 「ユーザエージェント」から、切り替えたいユーザ・エージェントを選択&lt;br /&gt;
・「開発」メニューが表示されない場合、「Safari」メニュー &amp;gt; 「環境設定」を開き、「詳細」タブで「メニューバーに”開発”メニューを表示」にチェックが入っていることを確認する&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
モバイルテンプレートを無効にする方法：&lt;/h4&gt;
・bloggerのメニューにある「テンプレート」タブを選択し、表示される画面にある歯車マークを選択して、「いいえ。携帯端末でPCテンプレートを表示する」を選択する&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyMobOL4V0rGG5EbTq8KxRMDk2mYXYx5oVRVmDH5Inn8lcB9KB1DMI9AMrEgIJcFNHdtoCzYTtGPWaf9gW6_ndikmwKEC8UL0x-ntgNlqi92u21Rxp2xkS83GJgHhtrQ1iDsJKlyfGL12J/s1600/blogger-mobile-template.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;220&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyMobOL4V0rGG5EbTq8KxRMDk2mYXYx5oVRVmDH5Inn8lcB9KB1DMI9AMrEgIJcFNHdtoCzYTtGPWaf9gW6_ndikmwKEC8UL0x-ntgNlqi92u21Rxp2xkS83GJgHhtrQ1iDsJKlyfGL12J/s320/blogger-mobile-template.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/6601259521800462013/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/6601259521800462013' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/6601259521800462013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/6601259521800462013'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2012/08/blogger.html' title='bloggerのモバイルテンプレート'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBwERKICJ0SY5PBQCba-Vu2NfQfXrrVkyhSjo0_JX2vbkAp2lulzYrKd_H4Jgm2dXxKOtWq0gYeeLHi2aG1jY1pHia76JlTkcnVyWlQtNnsD_1YCkS_I28v2cAniUnppDMX_R6uMnWEMOm/s72-c/blogger-pc-agent.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-8456180135165896740</id><published>2012-08-02T00:41:00.000+09:00</published><updated>2012-08-02T00:41:03.217+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="responsive"/><category scheme="http://www.blogger.com/atom/ns#" term="web design"/><title type='text'>レスポンシブデザインの勉強</title><content type='html'>最近、Web UIデザインの勉強を始めました。&lt;br /&gt;
流行のWeb UIデザインは、Responsive Designというらしく、これを試しに作成してみるため、&lt;a href=&quot;http://otonaka-responsive.blogspot.jp/&quot;&gt;オトなか　れすぽんしぶ&lt;/a&gt;というbloggerを新しく作成しました。&lt;br /&gt;
&lt;br /&gt;
最新の作成状況は、そちらのサイトで確認できます。</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/8456180135165896740/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/8456180135165896740' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/8456180135165896740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/8456180135165896740'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2012/08/blog-post.html' title='レスポンシブデザインの勉強'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-635592567221840858</id><published>2012-01-04T23:37:00.000+09:00</published><updated>2012-01-04T23:37:51.309+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django 1.3.1"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>DjangoでDateTimeを月や年でリスト取得する方法</title><content type='html'>DjangoでDateTimeを月や年でリストとして取得する方法&lt;br /&gt;
たとえば、blogなどで投稿がある月のみをリスト化したいときに、年・月のリストを取得するときに利用する方法&lt;br /&gt;
&lt;br /&gt;
Entryというテーブルのpub_dateというカラムをリスト取得する場合、&lt;br /&gt;
Entry.objects.dates(&#39;pub_date&#39;, &#39;year&#39;) -&amp;gt; 年でリスト取得&lt;br /&gt;
Entry.objects.dates(&#39;pub_date&#39;, &#39;month&#39;) -&amp;gt; 年・月でリスト取得&lt;br /&gt;
昇順でリストを取得したい場合、order=&#39;DESC&#39;を引数に追加する&lt;br /&gt;
&lt;br /&gt;
参考サイト&lt;br /&gt;
・&lt;a href=&quot;http://djangoproject.jp/doc/ja/1.0/ref/models/querysets.html#dates-field-kind-order-asc&quot;&gt;QuerySet API&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/635592567221840858/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/635592567221840858' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/635592567221840858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/635592567221840858'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2012/01/djangodatetime_04.html' title='DjangoでDateTimeを月や年でリスト取得する方法'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-4796277261925862862</id><published>2012-01-04T17:12:00.000+09:00</published><updated>2012-01-04T17:12:42.031+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django 1.3.1"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>DjangoでDateTime型をテンプレート内でフォーマッティングする方法</title><content type='html'>DjangoでDateTime型のパラメータをテンプレート内で、所望のフォーマットで表示する方法&lt;br /&gt;
&lt;br /&gt;
１．views.pyでは、他の型のパラメータと同じように、Dictionary型をContext型にフォーマッティングして、テンプレートに読み込ませる&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;import datetime
from django.template import loader, Context
from django.http import HttpResponse

def index(request):
    param1 = &#39;test&#39;
    param2 = datetime.datetime.now()
    template = loader.get_template(&#39;test.html&#39;)
    contexts = Context({&#39;param1&#39;:param1,
                        &#39;param2&#39;:param2,})
    return template.render(contexts)
&lt;/pre&gt;&lt;br /&gt;
テンプレート内では、次のようにフォーマッティングする&lt;br /&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;{{ param2|date:&quot;Y/n/d g:i A&quot; }}
&lt;/pre&gt;上のように指定すると、「2012/1/4 5:12 PM」と表示される&lt;br /&gt;
&lt;br /&gt;
参考サイト&lt;br /&gt;
・&lt;a href=&quot;https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#date&quot;&gt;Built in template tags and filters&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/4796277261925862862/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/4796277261925862862' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/4796277261925862862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/4796277261925862862'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2012/01/djangodatetime.html' title='DjangoでDateTime型をテンプレート内でフォーマッティングする方法'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-5441444924401982387</id><published>2012-01-01T18:43:00.000+09:00</published><updated>2012-01-01T18:43:14.817+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django 1.3.1"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>DjangoでSTATIC_URLをテンプレートで使う方法</title><content type='html'>STATIC_URLをテンプレートで参照できるようにする方法&lt;br /&gt;
&lt;br /&gt;
１．settings.pyに割り当てたいURLを記述する&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;STATIC_URL = &#39;http://localhost/static&#39;
&lt;/pre&gt;&lt;br /&gt;
２．views.pyでテンプレートを呼び出す時にRequestContextを利用する&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;from django.template import RequestContext, loader
from django.http import HttpResponse

def show(request):
    template = loader.get_template(&#39;show.html&#39;)
    contexts = RequestContext({})
    return HttpResponse(template.lender(contexts))
&lt;/pre&gt;&lt;br /&gt;
３．テンプレートファイル（show.html）でSTATIC_URLを使う&lt;br /&gt;
{{STATIC_URL}}と指定すると、settings.pyで定義した値を表示できる</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/5441444924401982387/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/5441444924401982387' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/5441444924401982387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/5441444924401982387'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2012/01/djangostaticurl.html' title='DjangoでSTATIC_URLをテンプレートで使う方法'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-2055725804556960771</id><published>2011-12-29T14:57:00.000+09:00</published><updated>2011-12-29T14:57:32.345+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring mvc"/><title type='text'>SpringFrameworkでWebアプリ作成</title><content type='html'>今までは、Python(Django)でWebアプリを作成していたが、これからはJavaで作らなければならなくなった&lt;br /&gt;
&lt;br /&gt;
いろいろとJavaのWebフレームワークを比較して、Spring MVC 3.1.0 Releaseで作成することにした&lt;br /&gt;
&lt;br /&gt;
DI (Dependency Injection)など、慣れない考え方で苦戦中だが、詰まったところを記録に残していく</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/2055725804556960771/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/2055725804556960771' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/2055725804556960771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/2055725804556960771'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/12/springframeworkweb.html' title='SpringFrameworkでWebアプリ作成'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-3103018070671066475</id><published>2011-10-30T00:42:00.000+09:00</published><updated>2011-10-30T00:42:01.376+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django"/><category scheme="http://www.blogger.com/atom/ns#" term="GAE"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Google App EngineでDjango</title><content type='html'>Google App Engineのサイト構築にDjangoフレームワークを利用する方法&lt;br /&gt;
詳細は&lt;a href=&quot;http://code.google.com/intl/ja/appengine/articles/appengine_helper_for_django.html&quot;&gt;ここ&lt;/a&gt;に書かれている&lt;br /&gt;
とりあえず、&lt;a href=&quot;http://code.google.com/p/google-app-engine-django/downloads/list&quot;&gt;ヘルパー&lt;/a&gt;をダウンロードしてきて、後はデータストア周り以外は普通にDjangoでプログラムを書けばよいみたい？</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/3103018070671066475/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/3103018070671066475' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/3103018070671066475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/3103018070671066475'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/10/google-app-enginedjango.html' title='Google App EngineでDjango'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-6967839838225131272</id><published>2011-09-19T01:01:00.000+09:00</published><updated>2011-09-19T01:01:29.202+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mac"/><category scheme="http://www.blogger.com/atom/ns#" term="opencv"/><category scheme="http://www.blogger.com/atom/ns#" term="port"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="インストール"/><title type='text'>MacへのOpenCVインストール</title><content type='html'>MacへOpenCVをインストール&lt;br /&gt;
Pythonから呼び出すため、Python 2.7とともにインストール&lt;br /&gt;
&lt;br /&gt;
今回は、ソースコードからではなく、MacPortsを利用してインストール&lt;br /&gt;
（依存モジュールが多いため）&lt;br /&gt;
&lt;br /&gt;
１．MacPortsのインストール&lt;br /&gt;
http://www.macports.org/からインストーラをダウンロードして、簡単にインストールできる&lt;br /&gt;
２．MacPortsでOpenCVをインストール&lt;br /&gt;
ターミナルを起動し、次のコマンドを実行すれば、インストールが開始する&lt;br /&gt;
# sudo port install opencv +python27&lt;br /&gt;
&lt;br /&gt;
・MacPortsでインストール中にPerlがエラーを起こした&lt;br /&gt;
&lt;pre&gt;Error: Target org.macports.activate returned: Image error: /opt/local/bin/a2p is being used by the active perl5.8 port.&amp;nbsp; Please deactivate this port first, or use &#39;port -f activate perl5&#39; to force the activation.
&lt;/pre&gt;エラー内にあるport -f activate perl5を実行しても、うまくいかなかった&lt;br /&gt;
対策としては、activeなperl5.8をアンインストールして、最新のPerlだけにすればよい&lt;br /&gt;
&lt;br /&gt;
手順は次の通り&lt;br /&gt;
１．インストールされているPerlを表示&lt;br /&gt;
&lt;pre&gt;# sudo port installed | grep perl
 perl5 @5.8.9_0
 perl5 @5.12.3_0+perl5_12
 perl5.8 @5.8.9_3 (active)
 perl5.12 @5.12.3_1 (active)
&lt;/pre&gt;２．インストールされているPerlの中から、古いバージョンのものをアンインストール&lt;br /&gt;
&lt;pre&gt;# sudo port uninstall perl5 @5.8.9_0
# sudo port uninstall perl5.8
&lt;/pre&gt;&lt;br /&gt;
これで、OpenCVのインストールを再会すればインストールできる&lt;br /&gt;
（インストールが完了するまでに、２時間ほどかかった・・・）</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/6967839838225131272/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/6967839838225131272' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/6967839838225131272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/6967839838225131272'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/09/macopencv.html' title='MacへのOpenCVインストール'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-7003826214463984075</id><published>2011-08-07T15:21:00.000+09:00</published><updated>2011-08-07T15:21:24.729+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="スクレイピング"/><title type='text'>HTTPレスポンスコードの取得</title><content type='html'>Pythonのurllib2を利用してWebサイトへアクセスしたときのHTTPレスポンスコードを利用するために、保存しておく方法&lt;br /&gt;
urllib2では、200以外はHTTPExceptionとなってしまうため、例外時の処理として書かなければならない&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;import urllib2

# HTTPレスポンスコードを格納する変数
http_code = 0
# アクセスするwebサイトのURL
url = &#39;http://www.yahoo.co.jp&#39;

try:
    # webサイトへアクセス
    web = urllib2.urlopen(url)
    # 成功した場合、この行以下も実行されるのでhttp_codeは200
    http_code = 200
except: HTTPError, e:
    http_code = e.code

print http_code
&lt;/pre&gt;これで、正しくWebサイトにアクセスできたかを確認できる&lt;br /&gt;
&lt;br /&gt;
参考サイト：&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://docs.python.org/howto/urllib2.html&quot;&gt;urllib2マニュアル&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/7003826214463984075/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/7003826214463984075' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/7003826214463984075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/7003826214463984075'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/08/http.html' title='HTTPレスポンスコードの取得'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-7598019182716525891</id><published>2011-08-07T00:01:00.000+09:00</published><updated>2011-08-07T00:01:01.044+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>実行ファイルの親ディレクトリのパスを取得</title><content type='html'>Pythonでプログラムを実行しているファイルの親ディレクトリのパスを取得する方法&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;import os
parent_path = os.path.abspath(os.path.dirname(__file__))
print parent_path
&lt;/pre&gt;例えば、/workspace/src/test.pyで実行した場合、parent_pathは&#39;/workspace/src&#39;となる</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/7598019182716525891/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/7598019182716525891' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/7598019182716525891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/7598019182716525891'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/08/blog-post.html' title='実行ファイルの親ディレクトリのパスを取得'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-7880561548804505971</id><published>2011-08-06T00:06:00.001+09:00</published><updated>2011-08-06T12:06:34.346+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="スクレイピング"/><title type='text'>PythonでWebのリンクリスト取得</title><content type='html'>BeautifulSoupを利用してWebサイトのページ内にあるリンクをリストとして取得する方法&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;import urllib2
from BeautifulSoup import BeautifulSoup

if __name__ == &#39;__main__&#39;:
    # アクセスするWebサイトのURL
    url = &#39;http://www.yahoo.co.jp/&#39;

    # Webサイトへアクセス
    web = urllib2.urlopen(url)
    # BeautifulSoupで解析できるよう読み込む
    html = BeautifulSoup(web)

    # &#39;a&#39;タグの全ての要素をリストとして抽出する
    base_linklist = self.getTagList(&#39;a&#39;)
    # 抽出した要素リストを1つずつ解析
    for link in base_linklist:
        # &#39;href&#39;がタグ内に含まれない場合は無視する
        if link.__str__().find(&#39;href=&#39;) != -1:
            # リンク名：リンクURLと表示
            print link.string.__str__() + &#39;:&#39; + link[&#39;href&#39;]
&lt;/pre&gt;リンク名が画像などの場合、link.stringはNoneが得られるため、文字列に変換しておく必要がある</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/7880561548804505971/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/7880561548804505971' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/7880561548804505971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/7880561548804505971'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/08/pythonweb.html' title='PythonでWebのリンクリスト取得'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-3202630022946560824</id><published>2011-08-05T15:38:00.001+09:00</published><updated>2011-08-05T15:50:59.286+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="スクレイピング"/><title type='text'>Pythonでスクレイピング(Cookie取得)</title><content type='html'>urllib2とcookielibでWebサイトへアクセスしたときに、Cookieを取得するサンプル&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;import urllib2, cookielib
from BeautifulSoup import BeautifulSoup

if __name__ == &#39;__main__&#39;:
    # アクセスするWebサイトのURLを設定
    url = &#39;http://www.google.co.jp&#39;

    # Cookieを格納するオブジェクト
    cookie = cookielib.CookieJar()
    # Webサイトへアクセスするオブジェクト
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
    # Webサイトへアクセス
    web = opener.open(url)
    # BeautifulSoupで解析
    html = BeautifulSoup(web)
    # 取得したCookie内容を表示
    print cookie
    # 取得したHTML内容を表示
    print html.prettify()
&lt;/pre&gt;&lt;br /&gt;
Cookieが設定されている場合、cookielib.CookieJarオブジェクトとして取得できる</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/3202630022946560824/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/3202630022946560824' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/3202630022946560824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/3202630022946560824'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/08/pythoncookie.html' title='Pythonでスクレイピング(Cookie取得)'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-6658380368213775300</id><published>2011-08-03T19:53:00.002+09:00</published><updated>2011-08-05T15:25:53.816+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="スクレイピング"/><title type='text'>Pythonでスクレイピング</title><content type='html'>Pythonでスクレイピングするライブラリとして&lt;a href=&quot;http://www.crummy.com/software/BeautifulSoup/&quot;&gt;BeautifulSoup&lt;/a&gt;を利用&lt;br /&gt;
&lt;br /&gt;
HTMLを取得して、それを表示する簡単なサンプル&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;import urllib2
from BeautifulSoup import BeautifulSoup

if __name__ == &#39;__main__&#39;:
    web = urllib2.urlopen(&#39;http://www.google.co.jp/&#39;)
    html = BeautifulSoup(web)
    print html.prettify()
&lt;/pre&gt;これで、指定したWebサイトのHTMLを取得/表示することができる</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/6658380368213775300/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/6658380368213775300' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/6658380368213775300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/6658380368213775300'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/08/python.html' title='Pythonでスクレイピング'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-5583869742127307343</id><published>2011-05-21T09:03:00.001+09:00</published><updated>2011-05-21T09:04:41.898+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Djangoのデータベースアクセス（その３）</title><content type='html'>&lt;span style=&quot;font-size: x-large;&quot;&gt;テーブルのデータを取得する方法&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;１．データを取得する関数の作成&lt;/span&gt;&lt;br /&gt;
sampleprj/sampleapp/views.pyにshowという関数を作成し、次のようなコードを書く&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;# encoding: utf-8
from django.http import HttpResponse 
from sampleprj.sampleapp.models import Memo
def show(request):
    memos = Memo.objects.all()
    for memo in memos:
        print memo.userid
        print memo.title
        print memo.content
    return HttpResponse(&#39;データを取得しました&#39;)
&lt;/pre&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;２．URL割り当て&lt;/span&gt;&lt;br /&gt;
show関数を割り当てるURLを定義する&lt;br /&gt;
sampleprj/urls.pyの最後に次のコードを追加する&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;urlpatterns += patterns(&#39;sampleprj.sampleapp&#39;,
url(r&#39;^sampleapp/show/$&#39;, &#39;show&#39;),
)
&lt;/pre&gt;&lt;br /&gt;
これでhttp://localhost:8000/sampleapp/show/にアクセスすると、コンソールにMemoテーブル内の全てのデータが表示される&lt;br /&gt;
&lt;br /&gt;
参考サイト：&lt;br /&gt;
・&lt;a href=&quot;http://djangoproject.jp/doc/ja/1.0/topics/db/queries.html&quot;&gt;クエリを生成する&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/5583869742127307343/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/5583869742127307343' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/5583869742127307343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/5583869742127307343'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/05/django_21.html' title='Djangoのデータベースアクセス（その３）'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-6117234671850528563</id><published>2011-05-14T15:22:00.000+09:00</published><updated>2011-05-14T15:22:44.201+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Djangoのデータベースアクセス（その２）</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-large;&quot;&gt;新規データを追加する方法&lt;/span&gt;&lt;br /&gt;
ユーザが、http://localhost:8000/sampleapp/add/にアクセスした時に、前回作成したテーブルに新規にデータを追加する手順&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;１．アクセスする関数の作成&lt;/span&gt;&lt;br /&gt;
sampleprj/sampleapp/views.pyにaddという関数を作成し、次のようなコードを書く&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;# encoding: utf-8
from django.http import HttpResponse
from sampleprj.sampleapp.models import Memo

def add(request):
&amp;nbsp;&amp;nbsp; &amp;nbsp;memo = Memo()
&amp;nbsp;&amp;nbsp; &amp;nbsp;memo.userid = 1
&amp;nbsp;&amp;nbsp; &amp;nbsp;memo.title = &#39;first memo&#39;
&amp;nbsp;&amp;nbsp; &amp;nbsp;memo.content = &#39;memo content&#39;
&amp;nbsp;&amp;nbsp; &amp;nbsp;return HttpResponse(&#39;データを追加しました&#39;)
&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;２．URL割り当て&lt;/span&gt;&lt;br /&gt;
add関数を割り当てるURLを定義する&lt;br /&gt;
sampleprj/urls.pyの最後に次のコードを追加する&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;urlpatterns += patterns(&#39;sampleprj.sampleapp&#39;,
&amp;nbsp;&amp;nbsp; &amp;nbsp;url(r&#39;^sampleapp/add/$&#39;, &#39;add&#39;),
)
&lt;/pre&gt;&lt;br /&gt;
これでhttp://localhost:8000/sampleapp/add/にアクセスするとテーブルに追加される。</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/6117234671850528563/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/6117234671850528563' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/6117234671850528563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/6117234671850528563'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/05/django_14.html' title='Djangoのデータベースアクセス（その２）'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-2666002617563556230</id><published>2011-05-07T23:51:00.002+09:00</published><updated>2011-05-07T23:54:35.367+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Djangoのデータベースアクセス（その１）</title><content type='html'>Djangoでデータベースへアクセスするためによく使う記述法のメモ&lt;br /&gt;
ここでは、まずテーブルを作成するまでの手順&lt;br /&gt;
次の例を利用する&lt;br /&gt;
プロジェクト名：sampleprj&lt;br /&gt;
アプリケーション名：sampleapp&lt;br /&gt;
テーブル名：Memo&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-large;&quot;&gt;データベースへのテーブル作成手順&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;１．モデルを定義&lt;/span&gt;&lt;br /&gt;
「sampleprj/sampleapp/models.py」に次のテーブル構成を追加&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;from django.db import models

class Memo(models.Model):
    userid = models.IntegerField()
    title = models.CharField(max_length=100)
    content = models.CharField(max_length=255)
    created_date = models.DateTimeField(auto_now_add=True)
    updated_date = models.DateTimeField(auto_now=True)
&lt;/pre&gt;テーブルの構成は、次の通り&lt;br /&gt;
・userid：ユーザID、整数型&lt;br /&gt;
・title：タイトル、文字列型、最大100文字まで&lt;br /&gt;
・content：内容、文字列型、最大255文字まで&lt;br /&gt;
・created_date：作成日時、日時型、作成日時を自動設定&lt;br /&gt;
・updated_date：更新日時、日時型、更新日時を自動設定&lt;br /&gt;
&lt;br /&gt;
models.py編集後に「# python manage.py syncdb」を実行することで、sampleapp_Memoというテーブルが作成される&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;参考サイト&lt;/span&gt;&lt;br /&gt;
・&lt;a href=&quot;http://djangoproject.jp/doc/ja/1.0/ref/models/fields.html&quot;&gt;モデルフィールドリファレンス&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/2666002617563556230/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/2666002617563556230' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/2666002617563556230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/2666002617563556230'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/05/django.html' title='Djangoのデータベースアクセス（その１）'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-4928677294489319547</id><published>2011-05-04T11:44:00.000+09:00</published><updated>2011-05-04T11:44:31.697+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="エラー"/><title type='text'>Djangoエラー：Non-ASCII character views.py, but no encoding declared</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;エラー内容&lt;/span&gt;&lt;br /&gt;
・ページにアクセスしたときに、「Non-ASCII character &#39;\xe3&#39; in file views.py on line 9, but no encoding declared;」というエラーが発生し、アクセスできない&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;原因&lt;/span&gt;&lt;br /&gt;
・日本語をファイル内で利用したが、文字コードを宣言しなかった&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;対処法&lt;/span&gt;&lt;br /&gt;
・日本語を利用したファイルの１行目に次のエンコーディング宣言を追加&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;# encoding: UTF-8
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/4928677294489319547/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/4928677294489319547' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/4928677294489319547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/4928677294489319547'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/05/djangonon-ascii-character-viewspy-but.html' title='Djangoエラー：Non-ASCII character views.py, but no encoding declared'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-5178418142198513297</id><published>2011-05-02T11:51:00.000+09:00</published><updated>2011-05-02T11:51:37.265+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="エラー"/><title type='text'>Djangoエラー：CSRF verification failed. Request aborted.</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;エラー内容&lt;/span&gt;&lt;br /&gt;
・djangoで、フォームに入力した内容をPOSTしたときに、「CSRF verification failed. Request aborted.」というエラー&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;対処法&lt;/span&gt;&lt;br /&gt;
・「(プロジェクトフォルダ)/settings.py」のMIDLEWARE_CLASSES内に次の１行を追加&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;&#39;django.middleware.csrf.CsrfResponseMiddleware&#39;,
&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;エラー画面&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWOpDhXZAt1x6piEFhsHUt38s_aPP6jJXXyRvVscF-1rUJHI_MSzOj7wwLA5VF6-fVuLpS6Y-CUp6OYJSTtTeO-0Kb9o8G0bIpRtxP2hW2HSo_JmAe0o8ybNMwE2lYGNbjl5V_Y9cPPoX3/s1600/CSRF+verification+failed+Request+aborted.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;223&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWOpDhXZAt1x6piEFhsHUt38s_aPP6jJXXyRvVscF-1rUJHI_MSzOj7wwLA5VF6-fVuLpS6Y-CUp6OYJSTtTeO-0Kb9o8G0bIpRtxP2hW2HSo_JmAe0o8ybNMwE2lYGNbjl5V_Y9cPPoX3/s320/CSRF+verification+failed+Request+aborted.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/5178418142198513297/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/5178418142198513297' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/5178418142198513297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/5178418142198513297'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/05/djangocsrf-verification-failed-request.html' title='Djangoエラー：CSRF verification failed. Request aborted.'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWOpDhXZAt1x6piEFhsHUt38s_aPP6jJXXyRvVscF-1rUJHI_MSzOj7wwLA5VF6-fVuLpS6Y-CUp6OYJSTtTeO-0Kb9o8G0bIpRtxP2hW2HSo_JmAe0o8ybNMwE2lYGNbjl5V_Y9cPPoX3/s72-c/CSRF+verification+failed+Request+aborted.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-2095211750117702140</id><published>2011-05-02T00:28:00.000+09:00</published><updated>2011-05-02T00:28:32.016+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="django"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>テンプレートからHTMLを読み込む手順</title><content type='html'>djangoでテンプレートからHTMLを読み込む手順&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;テンプレートディレクトリを追加&lt;/span&gt;&lt;br /&gt;
・「(プロジェクトディレクトリ)/settings.py」にあるTEMPLATE_DIRS = ()の中にディレクトリのパスを追加する&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;# 追加するディレクトリ：/home/project/templates
TEMPLATE_DIRS = (
&#39;/home/project/templates&#39;,
)
&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;テンプレートHTMLファイルを追加&lt;/span&gt;&lt;br /&gt;
・設定したテンプレートディレクトリ内に読み込むためのHTMLファイルを作成&lt;br /&gt;
例えば、&#39;/home/project/templates/sampleapp/index.htmlを追加&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;views側でテンプレートを読み込む&lt;/span&gt;&lt;br /&gt;
・テンプレートを表示したいアプリケーションのviews.pyにテンプレートを読み込むコードを挿入する&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;# 追加するアプリケーションが&#39;/home/project/sampleapp&#39;の場合、
# &#39;/home/project/sampleapp/views.py&#39;に次を追加
from django.http import HttpResponse
from django.template import Context, loader

def index(request):
&amp;nbsp;&amp;nbsp; &amp;nbsp;template = loader.get_template(&#39;sampleapp/index.html&#39;)
&amp;nbsp;&amp;nbsp; &amp;nbsp;return HttpResponse(template.render(Context()))
&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;URLを設定&lt;/span&gt;&lt;br /&gt;
・「(プロジェクトディレクトリ)/urls.py」にviewを登録する&lt;br /&gt;
・urlpatterns = (&#39;&#39;,)を次のように編集&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;urlpatterns = (&#39;&#39;,
&amp;nbsp;&amp;nbsp; &amp;nbsp;url(r&#39;^sampleapp/$&#39;, &#39;project.sampleapp.views.index&#39;),
)
&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;読み込みを確認&lt;/span&gt;&lt;br /&gt;
# python manage.py runserverを実行して、ブラウザでhttp://localhost:8000/sampleapp/にアクセスして表示されることを確認&lt;br /&gt;
&lt;br /&gt;
参考サイト：&lt;a href=&quot;http://djangoproject.jp/doc/ja/1.0/ref/templates/api.html&quot;&gt;テンプレートの利用方法&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/2095211750117702140/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/2095211750117702140' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/2095211750117702140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/2095211750117702140'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/05/html.html' title='テンプレートからHTMLを読み込む手順'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8456343801196608451.post-4855954462419394683</id><published>2011-05-01T18:59:00.000+09:00</published><updated>2011-05-01T18:59:56.433+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>プログラムの絶対パスを取得</title><content type='html'>Pythonで実行するプログラムの絶対パスを取得する方法&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;python&quot;&gt;print __file__
&lt;/pre&gt;&lt;br /&gt;
実行するプログラムの親ディレクトリを取得する方法&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;python&quot;&gt;import os
parent_dir = os.path.dirname(__file__)
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://otonaka.blogspot.com/feeds/4855954462419394683/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8456343801196608451/4855954462419394683' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/4855954462419394683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8456343801196608451/posts/default/4855954462419394683'/><link rel='alternate' type='text/html' href='http://otonaka.blogspot.com/2011/05/blog-post_01.html' title='プログラムの絶対パスを取得'/><author><name>Aqurro</name><uri>http://www.blogger.com/profile/02820298541255390241</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkyn1V4LYJ9orZT9fkoyMOdmJw1FDMiWxgubVLHIY3Cfv52vADzwrs7ay-yLc_QepvpyIg6G4SpoDsmB9nKcln-ZKGiVJJEtY9-Ht8m_jqFULzi2kppKbStJmeRUcPw/s220/Otonaka.jpg'/></author><thr:total>0</thr:total></entry></feed>