📜  管理命令 django - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:58.028000             🧑  作者: Mango

代码示例3
from django.core.management.base import BaseCommand
from django.utils import timezone

class Command(BaseCommand):
    help = 'Displays current time'

    def handle(self, *args, **kwargs):
        time = timezone.now().strftime('%X')
        self.stdout.write("It's now %s" % time)