LoginSignup
0
1

More than 5 years have passed since last update.

[django] カスタムコマンドを作る

Last updated at Posted at 2019-01-18
  • 作成したアプリケーション内に management/commands ディレクトリを作る
  • commands ディレクトリにpythonファイルを作成する
    • pythonファイルがコマンド名になる
作成したapp
└── management
    └── commands
       └── hoge.py
  • django.core.management.base.BaseCommand を使う
from django.core.management.base import BaseCommand, CommandError


class Command(BaseCommand):

    def handle(self, *args, **options):
        # 処理を書いていく

参考URL
https://docs.djangoproject.com/en/2.1/howto/custom-management-commands/

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1