我一直在用github自述文件中列出的简单示例测试django-kronos:
我做了pip3 install django-kronos
,
myproject / myapp / cron.py:
import kronos
import random
@kronos.register('* * * * *')
def complain():
complaints = [
"I forgot to migrate our applications's cron jobs to our new server! Darn!",
"I'm out of complaints! Damnit!"
]
print random.choice(complaints)
在我的myproject / myproject / settings.py中:
INSTALLED_APPS = [
'appointments.apps.AppointmentsConfig',
'clinic.apps.ClinicConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'bootstrap4',
'widget_tweaks',
'parsley',
'session_security',
'kronos'
]
Ran:
./manage.py runserver
我希望开发服务器每分钟抛出一条消息。似乎什么都没发生。
我还创建了myproject / myapp / management / commands / task.py:
from django.core.management.base import BaseCommand
import kronos
@kronos.register('* * * * *')
class Command(BaseCommand):
def handle(self, *args, **options):
print('Hello, world! KRONOS is running!!')
这也没有运行。