{"id":531,"date":"2021-04-29T18:34:31","date_gmt":"2021-04-29T09:34:31","guid":{"rendered":"http:\/\/www.agile-software.site\/?p=531"},"modified":"2021-04-29T20:47:30","modified_gmt":"2021-04-29T11:47:30","slug":"%e3%83%ac%e3%82%b9%e3%83%88%e3%83%a9%e3%83%b3%e6%a4%9c%e7%b4%a2%e3%82%b7%e3%82%b9%e3%83%86%e3%83%a0","status":"publish","type":"post","link":"https:\/\/agile-software.net\/?p=531","title":{"rendered":"\u30ec\u30b9\u30c8\u30e9\u30f3\u691c\u7d22\u30b7\u30b9\u30c6\u30e0"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">setting.py\u306e\u4fee\u6b63<\/h2>\n\n\n\nhttp:\/\/www.agile-software.site\/2021\/04\/24\/django-mysite-setting-py\/\n\n\n\n<p>STATIC_ROOT\u306b\u306fstatic\u30d5\u30a1\u30a4\u30eb\u304c\u51fa\u529b\u3055\u308c\u308b\u30d1\u30b9<br>STATICFILES_DIRS\u306b\u306f<code>STATIC_ROOT<\/code>\u306b\u8ffd\u52a0\u3067\u51fa\u529b\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u30d1\u30b9<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>STATIC_ROOT = os.path.join(BASE_DIR, &#39;staticfiles&#39;)\n\nSTATICFILES_DIRS = (\n    os.path.join(BASE_DIR, &#39;static&#39;),\n)<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">model<\/h2>\n\n\n\n<p>\u30ec\u30b9\u30c8\u30e9\u30f3\u3068\u90fd\u9053\u5e9c\u770c\u306eModel\u3092\u8ffd\u52a0<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>class Category(models.Model):\n    category_l = models.CharField(&quot;\u5927\u696d\u614b\u30b3\u30fc\u30c9&quot;, max_length=10, blank=False)\n    name = models.CharField(&quot;\u30ab\u30c6\u30b4\u30ea\u540d&quot;, max_length=30, blank=False)\n\n    def __str__(self):\n        return str(self.name)\n\n\nclass Pref(models.Model):\n    pref = models.CharField(&quot;\u90fd\u9053\u5e9c\u770c\u30b3\u30fc\u30c9&quot;, max_length=6, blank=False)\n    name = models.CharField(&quot;\u90fd\u9053\u5e9c\u770c\u540d&quot;, max_length=10, blank=False)\n\n    def __str__(self):\n        return str(self.name)<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ba1\u7406\u753b\u9762\u3067\u7ba1\u7406\u3067\u304d\u308b\u3088\u3046\u3059\u308b<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>from django.contrib import admin\nfrom .models import Category, Pref\n\n\n@admin.register(Category)\nclass CategoryAdmin(admin.ModelAdmin):\n    list_display = (&#39;category_l&#39;, &#39;name&#39;)\n    list_display_links = (&#39;category_l&#39;,)\n    list_editable = (&#39;name&#39;,)\n\n\n@admin.register(Pref)\nclass PrefAdmin(admin.ModelAdmin):\n    list_display = (&#39;pref&#39;, &#39;name&#39;)\n    list_display_links = (&#39;pref&#39;,)\n    list_editable = (&#39;name&#39;,)<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u7528\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u6307\u5b9a<\/h2>\n\n\n\n<p>path(&#8221;, include(&#8216;foodie.urls&#8217;))\u306f<strong>http:\/\/127.0.0.1:8000\/<\/strong>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068include()\u95a2\u6570\u3092\u4f7f\u3063\u3066foodie\u306eurls.py\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>from django.contrib import admin\nfrom django.urls import path, include # \u8ffd\u52a0\n\nurlpatterns = [\n    path(&#39;admin\/&#39;, admin.site.urls),\n    path(&#39;&#39;, include(&#39;foodie.urls&#39;)), # \u8ffd\u52a0\n]<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30c8\u30c3\u30d7\u30da\u30fc\u30b8(index)\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u6307\u5b9a<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"foodie\/urls.py\"><code>from django.urls import path\nfrom . import views\n\nurlpatterns = [\n    path(&#39;&#39;, views.IndexView.as_view(), name=&#39;index&#39;),\n]<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">context_processors\u8ffd\u52a0<\/h2>\n\n\n\n<p>\u5168\u3066\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067<code>pref_list<\/code>\u3068<code>category_list<\/code>\u304c\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>setting.py\u306e\u4fee\u6b63 STATIC_ROOT\u306b\u306fstatic\u30d5\u30a1\u30a4\u30eb\u304c\u51fa\u529b\u3055\u308c\u308b\u30d1\u30b9STATICFILES_DIRS\u306b\u306fSTATIC_ROOT\u306b\u8ffd\u52a0\u3067\u51fa\u529b\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u30d1\u30b9 model \u30ec\u30b9\u30c8\u30e9\u30f3\u3068\u90fd\u9053\u5e9c\u770c\u306eM<\/p>\n","protected":false},"author":1,"featured_media":532,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jin_ogp_image_url":"","_jin_last_featured_id":0,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-531","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-django"],"_links":{"self":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=531"}],"version-history":[{"count":2,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/531\/revisions"}],"predecessor-version":[{"id":537,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/posts\/531\/revisions\/537"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=\/wp\/v2\/media\/532"}],"wp:attachment":[{"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agile-software.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}