{"id":180,"date":"2009-09-12T01:26:23","date_gmt":"2009-09-11T16:26:23","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2009\/09\/12\/gae\/"},"modified":"2009-09-12T01:26:23","modified_gmt":"2009-09-11T16:26:23","slug":"gae","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2009\/09\/12\/gae\/","title":{"rendered":"GAE \u3067 \u30b8\u30e3\u30f3\u30b4\u30b8\u30e3\u30f3\u30b4\u30b8\u30e3\u30f3\u30b4 \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u3068\u3053\u307e\u3067"},"content":{"rendered":"<\/p>\n<p><a href=\"\/blg\/glob\/2009\/09\/gae_django.html\">GAE\u4e0a\u3067\u3001Django \u306e welcome \u30da\u30fc\u30b8\u307e\u3067\u306f\u306a\u3093\u3068\u304b\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u305f<\/a>\u306e\u3067\u3001\u6b21\u306f\u5358\u7d14\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u3002<\/p>\n<h2>1. \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u9aa8\u683c\u3092\u4f5c\u6210<\/h2>\n<p>Eclipse\u4e0a\u306e\u30bd\u30fc\u30b9\u30d5\u30a9\u30eb\u30c0\u3092\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u958b\u304d\u3001python manage.py startapp \u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<p>geatest \u3068\u3044\u3046\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u540d\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">C:\\Program Files\\eclipse3.4R2<\/pre>\n<p>\u305d\u3046\u3059\u308b\u3068\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u9aa8\u683c\u304c\u751f\u6210\u3055\u308c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u69cb\u6210\u306b\u306a\u308b\u3002<\/p>\n<p>gaetest \u30d5\u30a9\u30eb\u30c0(\u30d1\u30c3\u30b1\u30fc\u30b8)\u304c\u4f5c\u6210\u3055\u308c\u3001models.py \u3084 views.py \u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GAE_A82\/gae_django15.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"gae_django15\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GAE_A82\/gae_django15_thumb.jpg\" width=\"223\" height=\"178\" \/><\/a> <\/p>\n<h2>2. \u30e2\u30c7\u30eb\u306e\u4f5c\u6210<\/h2>\n<p>\u30e2\u30c7\u30eb\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p><u><font color=\"#ff0000\">Django \u6a19\u6e96\u306e\u30e2\u30c7\u30eb\u30af\u30e9\u30b9\u306f\u6a5f\u80fd\u3057\u306a\u3044<\/font><\/u>\u306e\u3067\u3001GAE Django \u30d8\u30eb\u30d1\u30fc\u304c\u63d0\u4f9b\u3059\u308b\u30e2\u30c7\u30eb\u30af\u30e9\u30b9\u3068\u3001GAE\u306e\u30c7\u30fc\u30bf\u30b9\u30c8\u30a2\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3059\u308b\u3002<\/p>\n<p>Django \u6a19\u6e96\u306e\u30e2\u30c7\u30eb\u30af\u30e9\u30b9\u306f\u6a5f\u80fd\u3057\u306a\u3044\u304c\u3001Django \u30e2\u30c7\u30eb\u3068\u540c\u69d8\u306b\u53d6\u308a\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u3001\u30e2\u30c7\u30eb\u306fDjango\u306b\u767b\u9332\u3055\u308c\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">from appengine_django.models import BaseModel\r\nfrom google.appengine.ext import db \r\n\r\n# Create your models here.\r\nclass GaeTest(BaseModel):\r\n    message = db.StringListProperty()\r\n    create_date = db.DateTimeProperty('data created')<\/pre>\n<h3>2.1 \u30e2\u30c7\u30eb\u306e\u6709\u52b9\u5316<\/h3>\n<p>GAE \u3067 Django \u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001RDBMS \u3092\u4f7f\u3048\u306a\u3044\u306e\u3067\u3001\u30e2\u30c7\u30eb\u306b\u5bfe\u5fdc\u3059\u308b\u30c6\u30fc\u30d6\u30eb\u7b49\u306f\u4f5c\u308b\u5fc5\u8981\u304c\u306a\u3044\u3002<\/p>\n<p>setting.py \u306eINSTALLED_APPS \u306b\u8a18\u8ff0\u3059\u308b\u3060\u3051\u3067\u3001\u6709\u52b9\u3068\u306a\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">INSTALLED_APPS = (\r\n     'appengine_django',\r\n     'gaetest',  # \u3053\u306e\u884c\u3092\u8ffd\u52a0\r\n)<\/pre>\n<h2>3. \u30d3\u30e5\u30fc\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4f5c\u6210<\/h2>\n<h3>3.1 URL\u30de\u30c3\u30d4\u30f3\u30b0\u306e\u4f5c\u6210<\/h3>\n<p>\u521d\u671f\u8868\u793a\u3067\u3001\u4fdd\u5b58\u3055\u308c\u305f\u30e2\u30c7\u30eb\u306e\u5185\u5bb9\u3092\u8868\u793a\u3057\u3001\u8ffd\u52a0\u30dc\u30bf\u30f3\u3067\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u60f3\u5b9a\u3002<\/p>\n<p>\u30bf\u30d7\u30eb\u306e1\u3064\u76ee\u306bURL\u306e\u30d1\u30bf\u30fc\u30f3\u30012\u3064\u76ee\u306b\u30ea\u30af\u30a8\u30b9\u30c8URL\u304c\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u5834\u5408\u306b\u51e6\u7406\u3059\u308b\u30cf\u30f3\u30c9\u30e9(\u30d3\u30e5\u30fc)\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">urlpatterns = patterns('',\r\n    (r'^gaetest\/$',     'gaetest.views.index'),  # \u521d\u671f\u8868\u793a\r\n    (r'^gaetest\/add\/$', 'gaetest.views.add'),    # \u30c7\u30fc\u30bf\u8ffd\u52a0\r\n)<\/pre>\n<h3>3.2 \u30d3\u30e5\u30fc\u306e\u4f5c\u6210<\/h3>\n<p>\u4e0a\u8a18 urls.py \u306b\u3066\u3001\u30ea\u30af\u30a8\u30b9\u30c8URL\u306e\u30d1\u30bf\u30fc\u30f3\u306b\u3088\u3063\u3066\u3001\u51e6\u7406\u3092\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3059\u308b<\/p>\n<p>\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3057\u3066\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3059\u3002\u3053\u306e\u3068\u304d\u3001\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u57cb\u3081\u8fbc\u307f(\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f\u3001render_to_response \u306b\u96a0\u853d\u3055\u308c\u3066\u3044\u308b\u304c)\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u305d\u308c\u3092\u53d6\u308a\u51fa\u3057\u3066\u63cf\u753b\u3055\u305b\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">from django.shortcuts import render_to_response\r\nfrom gaetest.models import GaeTest\r\nimport datetime\r\n\r\ndef index(request):\r\n    g_list = GaeTest.gql('order by message')\r\n    return render_to_response('gaetest\/index.html', {'g_list':g_list})\r\n    \r\ndef add(request):\r\n    msg = request.POST['message']\r\n    g = GaeTest(message=msg, create_date=datetime.datetime.now())\r\n    g.save()\r\n    g_list = GaeTest.gql('order by message')\r\n    return render_to_response('gaetest\/index.html', {'g_list':g_list})<\/pre>\n<h3>3.3 \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4f5c\u6210<\/h3>\n<p>\u4e0a\u8a18\u30d3\u30e5\u30fc\u3067\u3001\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u57cb\u3081\u8fbc\u307e\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5229\u7528\u3057\u3066\u3001\u753b\u9762\u63cf\u753b\u3092\u884c\u3046\u3002<\/p>\n<pre class=\"prettyprint linenums\">&lt;form method=&quot;post&quot; action=&quot;\/gaetest\/add\/&quot;&gt;\r\n    message:&lt;input name=&quot;message&quot; \/&gt;\r\n    &lt;input value=&quot;add&quot; type=&quot;submit&quot; \/&gt;\r\n&lt;\/form&gt;\r\n{% if g_list %}\r\n    &lt;ul&gt;\r\n    {% for g in g_list %}\r\n        &lt;li&gt;{{ g.message }}\r\n    {% endfor %}\r\n    &lt;\/li&gt;&lt;\/ul&gt;\r\n{% else %}\r\n    &lt;p&gt;No GaeTest are available.&lt;\/p&gt;\r\n{% endif %}    <\/pre>\n<h3>3.4 \u3053\u3053\u307e\u3067\u306e\u30d5\u30a1\u30a4\u30eb\u69cb\u6210<\/h3>\n<p>\u3053\u3053\u307e\u3067\u306e\u4f5c\u696d\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u69cb\u6210\u306b\u306a\u308b<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GAE_A82\/gae_django17.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"gae_django17\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GAE_A82\/gae_django17_thumb.jpg\" width=\"208\" height=\"215\" \/><\/a> <\/p>\n<h2>4.\u5b9f\u884c<\/h2>\n<p>\u3088\u3063\u3057\u3083\u3046\u3054\u3044\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GAE_A82\/gae_django18.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"gae_django18\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GAE_A82\/gae_django18_thumb.jpg\" width=\"273\" height=\"158\" \/><\/a> <\/p>\n<h2>5. \u305d\u306e\u4ed6<\/h2>\n<h3>5.1 \u7ba1\u7406\u30c4\u30fc\u30eb<\/h3>\n<p>Django \u306e\u7ba1\u7406\u30c4\u30fc\u30eb\u306f\u3001RDBMS \u3068\u5bc6\u63a5\u306b\u95a2\u9023\u3057\u3066\u304a\u308a\u3001RDBMS \u3092\u6301\u305f\u306a\u3044GAE\u3067\u306f\u3001\u63d0\u4f9b\u3055\u308c\u306a\u3044\u3002<\/p>\n<p>\u5225\u9014\u3001\/_ah\/admin \u3067\u7ba1\u7406\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u304c\u63d0\u4f9b\u3055\u308c\u308b\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GAE_A82\/gae_django16.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"gae_django16\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GAE_A82\/gae_django16_thumb.jpg\" width=\"249\" height=\"156\" \/><\/a> <\/p>\n<h3>5.2 \u5bfe\u8a71\u30b7\u30a7\u30eb<\/h3>\n<p>\u5bfe\u8a71\u30b7\u30a7\u30eb\u306b\u3066\u3001\u30e2\u30c7\u30eb\u306a\u3069\u306eAPI\u3092\u5229\u7528\u53ef\u80fd\u3002<\/p>\n<p>python manage.py shell \u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint linenums\">C:\\Program Files\\eclipse3.4R2\\workspace\\typea-services\\src&gt;python manage.py shell\r\n            :\r\nType &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.\r\n(InteractiveConsole)\r\n&gt;&gt;&gt; from gaetest.models import GaeTest\r\n&gt;&gt;&gt; import datetime\r\n&gt;&gt;&gt; g = GaeTest(message='first gae model.',create_date=datetime.datetime.now())\r\n&gt;&gt;&gt; g.save()\r\ndatastore_types.Key.from_path(u'GaeTest', 1, _app_id_namespace=u'typea-services' )<\/pre>\n<p>\u3044\u3058\u3087\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GAE\u4e0a\u3067\u3001Django \u306e welcome \u30da\u30fc\u30b8\u307e\u3067\u306f\u306a\u3093\u3068\u304b\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u305f\u306e\u3067\u3001\u6b21\u306f\u5358\u7d14\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u3002 1. \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u9aa8\u683c\u3092\u4f5c\u6210 Eclipse\u4e0a\u306e\u30bd\u30fc\u30b9\u30d5\u30a9\u30eb\u30c0\u3092\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u958b\u304d [&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,16,19],"tags":[],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-django","category-eclipse","category-googleappengine"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/180","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=180"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}