{"id":6013,"date":"2020-12-21T23:36:15","date_gmt":"2020-12-21T14:36:15","guid":{"rendered":"http:\/\/blog.jansnap.com\/?p=6013"},"modified":"2021-12-19T20:35:09","modified_gmt":"2021-12-19T11:35:09","slug":"django%e3%81%a7hidden%e5%b1%9e%e6%80%a7%e3%81%a7%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e5%87%ba%e5%8a%9b%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.jansnap.com\/?p=6013","title":{"rendered":"Django\u3067hidden\u5c5e\u6027\u3067\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u51fa\u529b\u3059\u308b"},"content":{"rendered":"<h2><span class=\"ez-toc-section\" id=\"%E6%A6%82%E8%A6%81\"><\/span>\u6982\u8981<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>Django\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u3001hidden\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u9805\u76ee\u540d\u3082\u8868\u793a\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u305f\u3044<\/li>\n<li>\u5165\u529b\u6b04\u3092<code>as_hidden<\/code>\u3067\u51fa\u529b\u3059\u308b\u3068\u3001\u9805\u76ee\u540d\u306f\u51fa\u3066\u3057\u307e\u3046\u3002\n<ul>\n<li>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u51fa\u529b\u3059\u308b\u969b\u3001\u76f4\u66f8\u304d\u305b\u305a\u306bfor\u6587\u3067\u56de\u3057\u3066\u53d6\u5f97\u3057\u3066\u3044\u308b\u5834\u5408\u3092\u60f3\u5b9a<\/li>\n<\/ul>\n<\/li>\n<li><code>is_hidden<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u5224\u5b9a\u3059\u308b<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"formspy\"><\/span>forms.py<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">class BuyerUserSignupForm(SignupForm):\n    userType = forms.IntegerField(initial=\"1\", widget=forms.HiddenInput)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"template\"><\/span>\ntemplate<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"html\" class=\"language-html\">  {% for field in form %}\n      <div class=\"field\">\n          {% if not field.is_hidden %}\n            {# \u901a\u5e38\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u30e9\u30d9\u30eb\u3068\u5165\u529b\u67a0\u3092\u51fa\u529b #}\n            {{ field.label_tag }}\n            {{ field }}\n            {% if field.help_text %}\n                <span class=\"helptext\">{{ field.help_text }}<\/span>\n            {% endif %}\n          {% else %}\n            {# hidden\u5c5e\u6027\u3067\u51fa\u529b #}\n            {{ field.as_hidden }}\n          {% endif %}\n          {% for error in field.errors %}\n            {{error}}\n          {% endfor %}\n          <\/div>\n  {% endfor %}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83\"><\/span>\n\u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><p><a href=\"https:\/\/metareal.blog\/2008\/05\/12\/checking-whether-field-has-a-hidden-widget-in-django-template\/\" rel=\"nofollow noopener\" target=\"_blank\">Django \u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u30d5\u30a9\u30fc\u30e0\u306e\u8981\u7d20\u304c hidden \u304b\u3069\u3046\u304b\u3092\u8abf\u3079\u308b<\/a><\/p><\/li><li><p><a href=\"http:\/\/imagawa.hatenadiary.jp\/entry\/20120520\/1337431689\" rel=\"nofollow noopener\" target=\"_blank\">Django\u306e\u30d5\u30a9\u30fc\u30e0\u306b\u5165\u529b\u3057\u305f\u5024\u3092\u96a0\u3057\u30d1\u30e9\u30e1\u30fc\u30bf\u3067\u5f15\u304d\u7d99\u3050<\/a><\/p><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<ul>\n<li>Django\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u3001hidden\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u9805\u76ee\u540d\u3082\u8868\u793a\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u305f\u3044<\/li>\n<li>\u5165\u529b\u6b04\u3092<code>as_hidden<\/code>\u3067\u51fa\u529b\u3059\u308b\u3068\u3001\u9805\u76ee\u540d\u306f\u51fa\u3066\u3057\u307e\u3046\u3002\n<ul>\n<li>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u51fa\u529b\u3059\u308b\u969b\u3001\u76f4\u66f8\u304d\u305b\u305a\u306bfor\u6587\u3067\u56de\u3057\u3066\u53d6\u5f97\u3057\u3066\u3044\u308b\u5834\u5408\u3092\u60f3\u5b9a<\/li>\n<\/ul>\n<\/li>\n<li>\n<code>is_hidden<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u5224\u5b9a\u3059\u308b<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4106,4108,4110,4070],"tags":[4103,4105,4109],"class_list":["post-6013","post","type-post","status-publish","format-standard","hentry","category-django","category-django30","category-hidden_field","category-python","tag-django","tag-django30","tag-hidden_field"],"_links":{"self":[{"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=\/wp\/v2\/posts\/6013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6013"}],"version-history":[{"count":2,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=\/wp\/v2\/posts\/6013\/revisions"}],"predecessor-version":[{"id":6278,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=\/wp\/v2\/posts\/6013\/revisions\/6278"}],"wp:attachment":[{"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}