{"id":3731,"date":"2011-11-21T04:14:39","date_gmt":"2011-11-20T19:14:39","guid":{"rendered":"http:\/\/mimumimu.net\/blog\/2011\/11\/21\/python-django-%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82-%e3%81%9d%e3%81%ae%ef%bc%93%ef%bc%8e%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f\/"},"modified":"2012-04-21T18:23:12","modified_gmt":"2012-04-21T09:23:12","slug":"python-django-%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82-%e3%81%9d%e3%81%ae%ef%bc%93%ef%bc%8e%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/mimumimu.net\/blog\/2011\/11\/21\/python-django-%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82-%e3%81%9d%e3%81%ae%ef%bc%93%ef%bc%8e%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e4%bd%bf%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f\/","title":{"rendered":"Python + Django \u3057\u3066\u307f\u305f\u3002 \u305d\u306e\uff13\uff0e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u4f7f\u3063\u3066\u307f\u305f\u3002"},"content":{"rendered":"<p>\u3069\u3082\u3001\u307f\u3080\u3089\u3093\u3067\u3059\u3002    <br \/><a href=\"http:\/\/mimumimu.net\/blog\/2011\/11\/21\/python-django-%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82-%e3%81%9d%e3%81%ae%ef%bc%92%ef%bc%8e%e3%81%a8%e3%82%8a%e3%81%82%e3%81%88%e3%81%9a%e3%83%9a%e3%83%bc%e3%82%b8%e3%82%92%e5%87%ba%e3%81%97\/\">\u7b2c\uff12\u56de<\/a>\u306e\u7d9a\u304d\u3063\u3066\u3053\u3068\u3067\u3002<\/p>\n<p>&#160;<\/p>\n<h3>\uff11\uff0e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u306a\u308b HTML \u30d5\u30a1\u30a4\u30eb\u3092\u66f8\u304f\u3002<\/h3>\n<p>test_project \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4ee5\u4e0b\u306b templates\/test_app \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3001    <br \/>templates\/test_app \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4ee5\u4e0b\u306b home.html \u3092\u4ee5\u4e0b\u306e\u5185\u5bb9\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:22dabe60-7094-4b99-bdda-31e77e74d184\" class=\"wlWriterEditableSmartContent\">\n<pre class=\"brush: python;\">&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;{{title}}&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n{% for i in data %}\n{{i}}&lt;br\/&gt;\n{% endblock %}\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<\/div>\n<p>{{\u5909\u6570}} \u3068\u3044\u3046\u306e\u3092\u3001\u300c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5909\u6570\u300d\u3068\u547c\u3073\u3001 <br \/>{{% \u30bf\u30b0 \u5f15\u6570 %}} \uff5e {{% end \u30bf\u30b0 %}} \u3068\u3044\u3046\u306e\u3092\u3001\u300c\u30bf\u30b0\u300d\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5909\u6570\u306e\u8a18\u8ff0\u3092\u7528\u3044\u3066\u3001\u5909\u6570\u306e\u4e2d\u8eab\u3092\u8868\u793a\u3055\u305b\u3001<br \/>\u30bf\u30b0\u306e\u8a18\u8ff0\u3092\u7528\u3044\u3066\u8868\u793a\u4e0a\u306e\u51e6\u7406\u3092\u8a18\u8ff0\u3059\u308b\u5f62\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a title=\"Django \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u8a00\u8a9e \u2014 Django v1.0 documentation\" href=\"http:\/\/djangoproject.jp\/doc\/ja\/1.0\/topics\/templates.html\">Django \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u8a00\u8a9e \u2014 Django v1.0 documentation<\/a> <br \/>\u3071\u30fc\u3063\u3068\u3053\u306e\u30da\u30fc\u30b8\u3092\u898b\u3066\u3044\u305f\u611f\u3058\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u8981\u7d20\u304c\u3088\u304f\u4f7f\u308f\u308c\u305d\u3046\u306a\u6c17\u304c\u3057\u307e\u3059\uff08\u3049<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\" width=\"571\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"175\">\n<p align=\"center\">\u30bf\u30b0\u540d<\/p>\n<\/td>\n<td valign=\"top\" width=\"394\">\n<p align=\"center\">\u5229\u7528\u7528\u9014<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"175\">extends [template file]<\/td>\n<td valign=\"top\" width=\"394\">\u3059\u3067\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u7d99\u627f\u3059\u308b\u3002<br \/>\n        <br \/>Java \u3067\u306e extend \u3068\u540c\u7fa9\u3068\u6349\u3048\u3089\u308c\u308b\u304b\u3082\u3002<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"175\">block [block name]<\/td>\n<td valign=\"top\" width=\"394\">\u7d99\u627f\u5143\uff1a\u30d6\u30ed\u30c3\u30af\uff08\u7bc4\u56f2\uff09\u3092\u5b9a\u7fa9\u3057\u3001\u7d99\u627f\u5148\u3067\u5024\u304c\u5909\u66f4\u3055\u308c\u308b\u5834\u6240\u3092\u8a2d\u5b9a\u3059\u308b\u3002<br \/>\n        <br \/>\u7d99\u627f\u5148\uff1a\u4e8b\u524d\u306b\u30d6\u30ed\u30c3\u30af\u3068\u3057\u3066\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u7bc4\u56f2\u306e\u30c6\u30ad\u30b9\u30c8\u3092\u5909\u66f4\u3059\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"175\">for [val1] in [val2]<\/td>\n<td valign=\"top\" width=\"394\">val2 \u304b\u3089\u8981\u7d20\u3092\uff11\u3064\uff11\u3064\u53d6\u308a\u51fa\u3057\u3001 val1 \u306b\u683c\u7d0d\u3059\u308b\u5f62\u3067\u3001<br \/>\n        <br \/>for ~ endfor \u9593\u3092\u7e70\u308a\u8fd4\u3059\u3002 <\/p>\n<p>Java \u3067\u8a00\u3046\u3068\u3053\u308d\u306e foreach \u304c\u3053\u308c\u306b\u8a72\u5f53\u3002 <\/p>\n<p>\u3061\u306a\u307f\u306b\u3001 Python \u306e for \u306f\u5168\u3066 foreach \u306a\u51e6\u7406\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"175\">if [\u6761\u4ef6] ~ else ~ endif<br \/>\n        <br \/>ifequal [val1] [val2] ~ endifequal <\/p>\n<p>ifnotequal [val1] [val2] endnotequal<\/td>\n<td valign=\"top\" width=\"394\">\u6761\u4ef6\u304c\u771f\u3067\u3042\u308c\u3070\u3001\u8a72\u5f53\u7bc4\u56f2\u304c\u5b9f\u884c\u3055\u308c\u308b\u3002\u901a\u5e38\u306e if \u6761\u4ef6\u3068\u540c\u3058\u3002<br \/>\n        <br \/>ifequal \u306f\uff12\u3064\u304c\u7b49\u3057\u3044\u5834\u5408\u3002 <\/p>\n<p>ifnotequal \u306f\uff12\u3064\u304c\u7b49\u3057\u304f\u306a\u3044\u5834\u5408\u306b\u305d\u308c\u305e\u308c\u5b9f\u884c\u3055\u308c\u308b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#160;<\/p>\n<h3>\uff12\uff0esettings.py \u306b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u7f6e\u304b\u308c\u3066\u3044\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30d1\u30b9\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/h3>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:642ba39a-771d-46b8-a0df-b6df00b33392\" class=\"wlWriterEditableSmartContent\">\n<pre class=\"brush: python;\">TEMPLATE_DIRS = (\n)<\/pre>\n<\/div>\n<p>\u3053\u3046\u306a\u3063\u3066\u3044\u308b\u90e8\u5206\u304c\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3053\u3053\u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:d3103bde-6105-40f2-998e-c5bc85330a4c\" class=\"wlWriterEditableSmartContent\">\n<pre class=\"brush: python;\">TEMPLATE_DIRS = (\n   '[test_project \u307e\u3067\u306e\u7d76\u5bfe\u30d1\u30b9]\/templates',\n)<\/pre>\n<\/div>\n<p>([test_project \u307e\u3067\u306e\u7d76\u5bfe\u30d1\u30b9] \u306b\u306f\u3001\u305d\u308c\u305e\u308c\u306e\u74b0\u5883\u306b\u5408\u3063\u305f\u30d1\u30b9\u3092\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff09<\/p>\n<p>&#160;<\/p>\n<h3>\uff13\uff0eviews.py \u3092\u7de8\u96c6\u3059\u308b\u3002<\/h3>\n<p>test_app \u306b\u79fb\u52d5\u3057\u3001views.py \u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:eaa93f04-1029-4dc7-bade-f901394866bf\" class=\"wlWriterEditableSmartContent\">\n<pre class=\"brush: python;\">from django.http import HttpResponse\nfrom django.template import loader, RequestContext\n\ndef home(req):\n    contexts = RequestContext(req, {\n        'title' : 'hello django!',\n        'data' : ('Hello', 'django', 'world'),\n    })\n    template = loader.get_template('test_app\/home.html')\n    return HttpResponse(template.render(contexts))<\/pre>\n<\/div>\n<p>&#160;<\/p>\n<h3>\uff14\uff0e\u5b9f\u884c\u3059\u308b\u3002<\/h3>\n<p><a href=\"http:\/\/mimumimu.net\/blog\/wp-content\/uploads\/2011\/11\/image23.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"http:\/\/mimumimu.net\/blog\/wp-content\/uploads\/2011\/11\/image_thumb23.png\" width=\"557\" height=\"342\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3082\u3001\u307f\u3080\u3089\u3093\u3067\u3059\u3002 \u7b2c\uff12\u56de\u306e\u7d9a\u304d\u3063\u3066\u3053\u3068\u3067\u3002 &#160; \uff11\uff0e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u306a\u308b HTML \u30d5\u30a1\u30a4\u30eb\u3092\u66f8\u304f\u3002 test_project \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4ee5\u4e0b\u306b templates\/test_app \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3001 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,14,7],"tags":[118,584,120],"class_list":["post-3731","post","type-post","status-publish","format-standard","hentry","category-python","category-web","category-dev","tag-django","tag-python","tag-120"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/posts\/3731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/comments?post=3731"}],"version-history":[{"count":0,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/posts\/3731\/revisions"}],"wp:attachment":[{"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/media?parent=3731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/categories?post=3731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mimumimu.net\/blog\/wp-json\/wp\/v2\/tags?post=3731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}