【问题标题】:Add to database cache from django_crontab从 django_crontab 添加到数据库缓存
【发布时间】:2018-11-25 00:10:18
【问题描述】:

我为 django_crontab 添加了设置

  INSTALLED_APPS = [
    ....
    'django_crontab',
    ....

]

和设置 cron

CRONJOBS = [
    ('* * * * *', 'app.cron.task'),
]

将任务方法添加到 app.cron

from .views import add_to_cache_table()


def task():
    add_to_cache_table()

并在 app.views 中创建了 add_to_cache_table() 方法:

from django.core.cache import cache


def add_to_cache_table():
   cache.add('key', 'value')

但是,当我尝试通过该键获取值表单缓存时,我得到 None。 我可以在 cron 中使用数据库缓存并写入它吗?

谢谢!

【问题讨论】:

    标签: django cron


    【解决方案1】:

    托管服务 (Pythonanywhere) 不支持用户的 crontab。

    https://github.com/kraiz/django-crontab/issues/14

    【讨论】:

    • 在 PythonAnywhere 上你应该使用他们的计划任务而不是自己设置 crontab
    猜你喜欢
    • 1970-01-01
    • 2018-04-23
    • 2018-02-18
    • 1970-01-01
    • 2016-04-16
    • 1970-01-01
    • 1970-01-01
    • 2012-10-06
    • 2020-08-08
    相关资源
    最近更新 更多