在已经添加到setting的app中添加模块management,在management下添加模块commands
就可以在commands下添加我们想添加的命令了(*.py)
举个栗子
#management.commands.hello.py 这是文件路径以及文件名
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def handle(self, *args, **options):
print('hello, world!')
在terminal中运行python3 manage.py hello即可看到hello, world!








网友评论