{"id":302,"date":"2011-08-05T15:05:12","date_gmt":"2011-08-05T06:05:12","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2011\/08\/05\/django_1\/"},"modified":"2011-08-05T15:05:12","modified_gmt":"2011-08-05T06:05:12","slug":"django_1","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2011\/08\/05\/django_1\/","title":{"rendered":"Django \u3067\u3061\u3087\u3063\u3068\u3057\u305f\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3059\u308b\u624b\u9806\u306e\u899a\u3048\u66f8\u304d (1)"},"content":{"rendered":"<p>\u3061\u3087\u3063\u3068\u3057\u305f \u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3 Web\u30a2\u30d7\u30ea\u3092\u3064\u304f\u308b\u306e\u306b\u3001Django \u4fbf\u5229\u3002<\/p>\n<p>DB\u30ab\u30e9\u30e0\u306e\u8ad6\u7406\u540d\u3001\u7269\u7406\u540d\u5909\u63db\u3068\u304b\u3001SQL\u3092\u751f\u6210\u3057\u305f\u308a\u3068\u304b\u3059\u308b\u3088\u3046\u306a\u30c4\u30fc\u30eb\u3092 Web\u30a2\u30d7\u30ea\u3067\u3064\u304f\u3063\u3066\u304a\u304f\u3068\u30c1\u30fc\u30e0\u9593\u3067\u5171\u6709\u3067\u304d\u308b\u3057Excel\u30de\u30af\u30ed\u3088\u308a\u4f7f\u3044\u52dd\u624b\u304c\u826f\u3044\u5834\u5408\u3082\u3057\u3070\u3057\u3070\u3002\u3057\u304b\u3082\u7c21\u5358\u306b\u3064\u304f\u308c\u3066\u3001Python\u306e\u30d1\u30ef\u30d5\u30eb\u3055\u3092\u5341\u5168\u306b\u5229\u7528\u3067\u304d\u308b\u3002<\/p>\n<p>\u305f\u3060\u3001\u305d\u3093\u306a\u306b\u983b\u7e41\u306b\u3064\u304f\u308b\u3082\u306e\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u624b\u9806\u3092\u5fd8\u308c\u304c\u3061\u3002\u7c21\u5358\u306b\u52d5\u304b\u3059\u3068\u3053\u308d\u307e\u3067\u3092\u30e1\u30e2\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>&#160;<\/p>\n<h2>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h2>\n<p><a href=\"https:\/\/www.djangoproject.com\/download\/\">Django Download<\/a> \u304b\u3089\u3001<a href=\"http:\/\/www.djangoproject.com\/download\/1.3\/tarball\/\">Django-1.3.tar.gz<\/a> \u3042\u305f\u308a\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3002<\/p>\n<p>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u89e3\u51cd\u3002<\/p>\n<p>\u3059\u308b\u306e\u3060\u304c\u3001<a href=\"http:\/\/itpro.nikkeibp.co.jp\/article\/COLUMN\/20060228\/231198\/\">tar.gz<\/a>&#160; \u3067\u5727\u7e2e\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001Windows 7 \u306e\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u30fc\u304b\u3089\u89e3\u51cd\u3067\u304d\u306a\u3044\u3002<\/p>\n<p>\u3053\u3046\u3044\u3046\u3068\u304d\u3001<a href=\"http:\/\/www.cygwin.com\/\">Cygwin<\/a> \u3092\u5165\u308c\u3066\u304a\u304f\u3068\u4fbf\u5229\u3002\u4e0a\u8a18\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3001Cygwin\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u884c\u3063\u3066\u3001\u89e3\u51cd\u3092\u884c\u3046\u3002Windows \u306e\u30c9\u30e9\u30a4\u30d6\u306f\u3001cygdrive \u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3055\u308c\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">$ cd \/cygdrive\/C\/Users\/piroto\/Downloads\r\n$ tar -xvf Django-1.3.tar.gz<\/pre>\n<p>\u4e0a\u8a18\u306e\u5834\u5408\u3001\u89e3\u51cd\u3055\u308c\u308b\u3068\u3001<\/p>\n<pre class=\"prettyprint linenums\">C:\\Users\\piroto\\Downloads\\Django-1.3<\/pre>\n<p>\u3068\u3044\u3046\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u4f5c\u6210\u3055\u308c\u308b\u3002<\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c<\/p>\n<pre class=\"prettyprint linenums\">C:\\Users\\piroto\\Downloads\\Django-1.3&gt;python setup.py install<\/pre>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306e\u78ba\u8a8d<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30a8\u30e9\u30fc\u304c\u3067\u306a\u3051\u308c\u3070OK <\/p>\n<pre class=\"prettyprint linenums\">C:\\Users\\piroto\\Downloads\\Django-1.3&gt;python\r\nPython 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32\r\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\r\n&gt;&gt;&gt; import django\r\n&gt;&gt;&gt;<\/pre>\n<h2>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210<\/h2>\n<h3>Eclipse \u306bPyDev \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>Help \u2013 Install New Software \u304b\u3089\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30b5\u30a4\u30c8URL \u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<p><a title=\"http:\/\/pydev.org\/updates\/\" href=\"http:\/\/pydev.org\/updates\/\">http:\/\/pydev.org\/updates\/<\/a><\/p>\n<h3>PyDev\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210<\/h3>\n<p>Eclipse \u304b\u3089 File \u2013 New \u2013 Other \u304b\u3089 PyDev \u30b0\u30eb\u30fc\u30d7\u3092\u9078\u629e\u3057\u3001PyDev Django Projecto \u3092\u4f5c\u6210\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"603\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"200\">\u30d5\u30a1\u30a4\u30eb<\/td>\n<td valign=\"top\" width=\"401\">\u6982\u8981<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"200\">__init__.py<\/td>\n<td valign=\"top\" width=\"401\">\u3053\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u30d1\u30c3\u30b1\u30fc\u30b8\u3060\u3068<a href=\"http:\/\/typea.info\/tips\/wiki.cgi?page=Python\">Python<\/a>\u306b\u4f1d\u3048\u308b\u7a7a\u306e\u30d5\u30a1\u30a4\u30eb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"200\">manage.py<\/td>\n<td valign=\"top\" width=\"401\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3068\u5bfe\u8a71\u3059\u308b\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"200\">settings.py<\/td>\n<td valign=\"top\" width=\"401\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"200\">urls.py<\/td>\n<td valign=\"top\" width=\"401\">\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306eURL\u5ba3\u8a00<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>&#160;<\/h3>\n<h3>Django\u306e\u5b9f\u884c<\/h3>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30e1\u30cb\u30e5\u30fc\u304b\u3089\u3001Run As -&#160; PyDev : Django \u3067\u3001Django \u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3057\u3001\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3002<\/p>\n<p>\u300cIt workd!\u300d \u3068\u51fa\u308b\u306f\u305a\u3002<\/p>\n<h2><\/h2>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/5198e944b0ae_AF6A\/django01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"django01\" border=\"0\" alt=\"django01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/5198e944b0ae_AF6A\/django01_thumb.jpg\" width=\"394\" height=\"248\" \/><\/a> <\/p>\n<h2>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u4f5c\u6210<\/h2>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30e1\u30cb\u30e5\u30fc\u304b\u3089\u3001Django -&#160; Create application(manage.py startapp) \u3092\u9078\u629e\u3057\u3001\u540d\u79f0\u3092\u8a2d\u5b9a(\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f\u3001model_name_util)\u3057\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/5198e944b0ae_AF6A\/django02.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"django02\" border=\"0\" alt=\"django02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/5198e944b0ae_AF6A\/django02_thumb.jpg\" width=\"280\" height=\"292\" \/><\/a> <\/p>\n<h2>URL\u306e\u8a2d\u8a08<\/h2>\n<p>\u4ee5\u4e0b\u306e\u66f8\u5f0f\u306b\u5f93\u3063\u3066\u3001URL\u306e\u30ea\u30b9\u30c8\u3092\u3001urls.py \u306b\u8a18\u8ff0\u3059\u308b\u3002\u6b63\u898f\u8868\u73fe\u306b\u4e00\u81f4\u3059\u308b\u30ea\u30b9\u30c8\u306e\u3001Python \u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u3002<\/p>\n<pre class=\"prettyprint linenums\">(\u6b63\u898f\u8868\u73fe, Python \u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570 [, \u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u30c7\u30a3\u30af\u30b7\u30e7\u30ca\u30ea])<\/pre>\n<p>\/model_name_util\/ \u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u3001webapp_util.model_name_util.views \u30e2\u30b8\u30e5\u30fc\u30eb\u306e index \u95a2\u6570\u304c\u51e6\u7406\u3059\u308b\u3088\u3046\u306b urls.py \u306b\u8a2d\u5b9a<\/p>\n<h4>urls.py<\/h4>\n<pre class=\"prettyprint linenums\">urlpatterns = patterns('',\r\n    (r'^model_name_util\/$', 'webapp_util.model_name_util.views.index'),\r\n)<\/pre>\n<h3>index\u95a2\u6570\u306e\u5b9f\u88c5<\/h3>\n<p>\u547c\u3073\u51fa\u3055\u308c\u308b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092 views.py \u306b\u5b9f\u88c5\u3002<\/p>\n<p>HTML\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3057\u3066\u547c\u3073\u51fa\u3057\u3001\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u5024\u3092\u8a70\u3081\u3066\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3092\u884c\u3046<\/p>\n<p>\u3002<\/p>\n<pre class=\"prettyprint linenums\">from django.template import Context, loader\r\nfrom django.http import HttpResponse\r\n\r\ndef index(request):\r\n    t = loader.get_template('model_name_util\/index.html')\r\n    c = Context({\r\n                 'message':'Hello Django World.'\r\n                 })\r\n    return HttpResponse(t.render(c))<\/pre>\n<h3>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4f5c\u6210<\/h3>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u3001settings.py \u306e TEMPLATE_DIR \u306b\u6307\u5b9a\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30ea\u306b\u4f5c\u6210\u3059\u308b\u3002\u5148\u982d\u306f\u30b9\u30e9\u30c3\u30b7\u30e5\u3067\u59cb\u307e\u308b\u5fc5\u8981\u304c\u3042\u308a(Windows\u3067\u3082)\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u7d76\u5bfe\u30d1\u30b9\u3002(\u3061\u3068\u9762\u5012\u304f\u3055\u3044)<\/p>\n<h4>settings.py<\/h4>\n<pre class=\"prettyprint linenums\">TEMPLATE_DIRS = (\r\n    # Put strings here, like &quot;\/home\/html\/django_templates&quot; or &quot;C:\/www\/django\/templates&quot;.\r\n    # Always use forward slashes, even on Windows.\r\n    # Don't forget to use absolute paths, not relative paths.\r\n    &quot;\/Users\/piroto\/workspace_test\/webapp_util\/src\/template&quot;\r\n)<\/pre>\n<h4>index.html<\/h4>\n<pre class=\"prettyprint linenums\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    Django Template. &lt;br\/&gt;\r\n    {{message}}&lt;br\/&gt;\r\n    settings.py \u306e TEMPLATE_DIRS \u306b\u7d76\u5bfe\u30d1\u30b9\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u6ce8\u610f!\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h3>\u5168\u4f53\u306e\u69cb\u6210<\/h3>\n<p>\u3053\u306e\u6642\u70b9\u3067\u5168\u4f53\u306e\u69cb\u6210\u306f\u3001\u3053\u3093\u306a\u611f\u3058<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/5198e944b0ae_AF6A\/django03.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"django03\" border=\"0\" alt=\"django03\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/5198e944b0ae_AF6A\/django03_thumb.jpg\" width=\"243\" height=\"348\" \/><\/a> <\/p>\n<h2>\u4e00\u65e6\u5b9f\u884c<\/h2>\n<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/5198e944b0ae_AF6A\/django04.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px\" title=\"django04\" border=\"0\" alt=\"django04\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/5198e944b0ae_AF6A\/django04_thumb.jpg\" width=\"582\" height=\"322\" \/><\/a> <\/p>\n<p>\u3061\u3083\u3093\u3068\u52d5\u3044\u3066\u3044\u308b\u3088\u3046\u3060\u3002<\/p>\n<p>Model \u306f\u6b21\u56de\u3002<\/p>\n<p><iframe style=\"width: 120px; height: 240px\" marginheight=\"0\" src=\"http:\/\/rcm-jp.amazon.co.jp\/e\/cm?lt1=_blank&amp;bc1=FFFFFF&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=typea09-22&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=ss_til&amp;asins=4048672096\" frameborder=\"0\" marginwidth=\"0\" scrolling=\"no\"><\/iframe><iframe style=\"width: 120px; height: 240px\" marginheight=\"0\" src=\"http:\/\/rcm-jp.amazon.co.jp\/e\/cm?lt1=_blank&amp;bc1=FFFFFF&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=typea09-22&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=ss_til&amp;asins=477413760X\" frameborder=\"0\" marginwidth=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3061\u3087\u3063\u3068\u3057\u305f \u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3 Web\u30a2\u30d7\u30ea\u3092\u3064\u304f\u308b\u306e\u306b\u3001Django \u4fbf\u5229\u3002 DB\u30ab\u30e9\u30e0\u306e\u8ad6\u7406\u540d\u3001\u7269\u7406\u540d\u5909\u63db\u3068\u304b\u3001SQL\u3092\u751f\u6210\u3057\u305f\u308a\u3068\u304b\u3059\u308b\u3088\u3046\u306a\u30c4\u30fc\u30eb\u3092 Web\u30a2\u30d7\u30ea\u3067\u3064\u304f\u3063\u3066\u304a\u304f\u3068\u30c1\u30fc\u30e0\u9593\u3067\u5171\u6709\u3067\u304d\u308b\u3057Excel\u30de\u30af [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[29,20],"tags":[],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-django","category-python"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}