{"id":6047,"date":"2018-12-13T02:51:22","date_gmt":"2018-12-12T17:51:22","guid":{"rendered":"http:\/\/blog.jansnap.com\/?p=6047"},"modified":"2021-12-15T01:46:00","modified_gmt":"2021-12-14T16:46:00","slug":"%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%20django-admin%20%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%81%ab%e3%80%81%e7%8b%ac%e8%87%aa%e5%bc%95%e6%95%b0%e3%82%92%e8%bf%bd%e5%8a%a0%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.jansnap.com\/?p=6047","title":{"rendered":"\u30ab\u30b9\u30bf\u30e0 django-admin \u30b3\u30de\u30f3\u30c9\u306b\u3001\u72ec\u81ea\u5f15\u6570\u3092\u8ffd\u52a0\u3059\u308b"},"content":{"rendered":"<p>\u524d\u56de\u306e\u8a18\u4e8b\u300c<a href=\"https:\/\/qiita.com\/jansnap\/items\/d50f59dabc5da7c1d0dd\" id=\"reference-c8e2c618ae95357452f2\">\u30ab\u30b9\u30bf\u30e0 django-admin \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u88c5\u3057\u3066\u3001\u5916\u90e8\u304b\u3089\u30a2\u30d7\u30ea\u5185\u306e\u30e2\u30c7\u30eb\u3092\u4f7f\u3046<\/a>\u300d\u306e\u7d9a\u304d\u3067\u3059\u3002<\/p>\n\n<h2><span class=\"ez-toc-section\" id=\"%E8%83%8C%E6%99%AF\"><\/span>\n\u80cc\u666f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n<p>\u524d\u56de\u306f\u3001\u30ab\u30b9\u30bf\u30e0\u30b3\u30de\u30f3\u30c9\u3068\u3057\u3066\u3001\u300ccrawler\u300d\u3092\u8ffd\u52a0\u3057\u3001<code>$ python manage.py crawler<\/code>\u3067\u3001\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<br>\n\u4eca\u56de\u306f\u3001\u305d\u306e\u30b3\u30de\u30f3\u30c9\u306b\u5f15\u6570\u3092\u6e21\u3057\u3066\u3001\u51e6\u7406\u3092\u5207\u308a\u66ff\u3048\u3089\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n<h2><span class=\"ez-toc-section\" id=\"%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E3%81%AE%E3%82%B3%E3%83%BC%E3%83%89\"><\/span>\n\u30b5\u30f3\u30d7\u30eb\u306e\u30b3\u30fc\u30c9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n<ul>\n<li>\n<code>add_arguments<\/code>\u3068\u3044\u3046\u95a2\u6570\u3092\u5b9f\u88c5\u3057\u3001\u5f15\u6570\u306e\u6271\u3044\u65b9\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">from django.core.management.base import BaseCommand, CommandError\nfrom app1.models import Topic\n\nclass Command(BaseCommand):\n  help = 'crawler for test.'\n\n  def add_arguments(self, parser):\n    parser.add_argument('-c', '--check-alive', action='store_true', dest='check-alive', help='Check topic alive.')\n\n  def handle(self, *args, **options):\n    #self.myprint(\"options=%s\" % options)\n    if not options['check-alive']:\n      self.crawl_new()\n    else:\n      self.check_alive()\n\n  def crawl_new(self):\n    self.myprint('this is function crawl_new.')\n\n  def check_alive(self):\n    self.myprint('this is function check_alive.')\n<\/code><\/pre>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"%E8%A6%81%E7%82%B9\"><\/span>\n\u8981\u70b9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n<ul>\n<li>\n<p>\u5f15\u6570\u306f\u3001<code>--version<\/code>\u306e\u3088\u3046\u306b\u5f8c\u7d9a\u306e\u5f15\u6570\u304c\u7121\u3044\u3082\u306e\u3068\u3001<code>--verbosity 3<\/code>\u306e\u3088\u3046\u306b\u5f8c\u7d9a\u306e\u5f15\u6570\u304c\u6709\u308b\u3082\u306e\u306e2\u7a2e\u985e\u306b\u5206\u3051\u3089\u308c\u307e\u3059\u3002<\/p>\n\n<ul>\n<li>\u5f8c\u7d9a\u306e\u5f15\u6570\u304c\u7121\u3044\u5834\u5408\u306f\u3001<code>action='store_true'<\/code>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002(\u3053\u308c\u306e\u8a73\u3057\u3044\u89e3\u8aac\u8a18\u4e8b\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f)\u3002\u5f15\u6570\u304c\u6307\u5b9a\u3055\u308c\u305f\u304b\u5426\u304b\u306f\u3001True\/False\u3067\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002<\/li>\n<li>\u5f8c\u7d9a\u306e\u5f15\u6570\u304c\u6709\u308b\u5834\u5408\u306f\u3001<code>nargs='*'<\/code>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u5f8c\u7d9a\u306e\u5f15\u6570\u306f\u8f9e\u66f8\u578b\u3067\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002\u5f8c\u7d9a\u306e\u5f15\u6570\u304c\u7701\u7565\u3055\u308c\u305f\u5834\u5408\u306f\u3001\u7a7a\u306e\u8f9e\u66f8\u304c\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u3055\u3089\u306b\u3001<code>dest='check-alive'<\/code>\u3067\u3001\u5f15\u6570\u304c\u3069\u306e\u3088\u3046\u306b\u6307\u5b9a\u3055\u308c\u305f\u304b\u3092<code>options<\/code>\u306b\u3069\u3093\u306a\u30ad\u30fc\u3067\u683c\u7d0d\u3059\u308b\u304b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n<ul>\n<li>\u3053\u306e\u6307\u5b9a\u304c\u7121\u3044\u3068\u3001\u5f15\u6570\u540d\u306e\u9577\u3044\u65b9\u306e\u540d\u524d\u3067\u3001<code>-<\/code>\u3092<code>_<\/code>\u306b\u5909\u63db\u3057\u305f\u30ad\u30fc\u3067\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002(\u4e0a\u8a18\u306e\u4f8b\u3067\u306f<code>options['check_alive']<\/code>)\u3002<\/li>\n<li>\u5f15\u6570\u306b\u9577\u3044\u540d\u524d\u306e\u5834\u5408\u306f\u30cf\u30a4\u30d5\u30f3\u3092\u4f7f\u3046\u5834\u5408\u304c\u591a\u3044\u306e\u3067\u3001dest\u3092\u6307\u5b9a\u3057\u305f\u65b9\u304c\u7121\u96e3\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n<h2><span class=\"ez-toc-section\" id=\"%E6%B0%97%E3%81%AB%E3%81%AA%E3%82%8B%E7%82%B9\"><\/span>\n\u6c17\u306b\u306a\u308b\u70b9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n<ul>\n<li>\u4e0a\u8a18\u306e\u5834\u5408\u3001<code>-c<\/code>\u306e\u4ee3\u308f\u308a\u306b<code>-cc<\/code>\u3084<code>-cccccccc<\/code>\u306e\u3088\u3046\u306b\u540c\u3058\u6587\u5b57\u3092\u91cd\u306d\u3066\u6307\u5b9a\u3057\u3066\u3082\u540c\u3058\u7d50\u679c\u306b\u306a\u308a\u307e\u3059\u304c\u3001<code>-c1<\/code>\u306e\u3088\u3046\u306b\u7570\u306a\u308b\u6587\u5b57\u3092\u6307\u5b9a\u3059\u308b\u3068<code>error: argument -c\/--check-alive: ignored explicit argument '1'<\/code>\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002\u9577\u3044\u5f15\u6570\u306e\u5834\u5408\u306f<code>--check-alivee<\/code>\u306e\u3088\u3046\u306b\u672b\u5c3e\u306e\u540c\u3058\u6587\u5b57\u3092\u91cd\u306d\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n<\/ul>\n\n<h2><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83%E3%82%B5%E3%82%A4%E3%83%88\"><\/span>\n\u53c2\u8003\u30b5\u30a4\u30c8<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n<ul>\n<li><p>\u516c\u5f0f\u30da\u30fc\u30b8\u306e<a href=\"https:\/\/docs.djangoproject.com\/ja\/2.1\/howto\/custom-management-commands\/#accepting-optional-arguments\" rel=\"nofollow noopener\" target=\"_blank\">\u30ab\u30b9\u30bf\u30e0 django-admin \u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u88c5<\/a><\/p><\/li>\n<li><p>\u516c\u5f0f\u30da\u30fc\u30b8\u306e<a href=\"https:\/\/docs.python.org\/ja\/3.6\/library\/argparse.html#the-add-argument-method\" rel=\"nofollow noopener\" target=\"_blank\">16.4.3. add_argument() \u30e1\u30bd\u30c3\u30c9<\/a><\/p><\/li>\n<li><p><a href=\"https:\/\/qiita.com\/checkpoint\/items\/b6947501774b4008e077\" id=\"reference-43dca328c2054344170d\">Django\u306e\u30ab\u30b9\u30bf\u30e0\u30b3\u30de\u30f3\u30c9\u3092\u4f5c\u6210\u3057\u3066\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089\u5b9f\u884c\u3059\u308b<\/a><\/p><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306e\u8a18\u4e8b\u300c<a href=\"https:\/\/qiita.com\/jansnap\/items\/d50f59dabc5da7c1d0dd\" id=\"reference-c8e2c618ae95357452f2\">\u30ab\u30b9\u30bf\u30e0 django-admin \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u88c5\u3057\u3066\u3001\u5916\u90e8\u304b\u3089\u30a2\u30d7\u30ea\u5185\u306e\u30e2\u30c7\u30eb\u3092\u4f7f\u3046<\/a>\u300d\u306e\u7d9a\u304d\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4106,4209,4070,4071],"tags":[4103,4208,4065,4066],"class_list":["post-6047","post","type-post","status-publish","format-standard","hentry","category-django","category-django21","category-python","category-python3","tag-django","tag-django21","tag-python","tag-python3"],"_links":{"self":[{"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=\/wp\/v2\/posts\/6047","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=6047"}],"version-history":[{"count":0,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=\/wp\/v2\/posts\/6047\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jansnap.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}