Python Django查询在cron作业下不工作

Python Django查询在cron作业下不工作,python,django,cron,Python,Django,Cron,我想在django user中创建一个cron作业,用于向用户发送电子邮件 all_user_result = AssesmentRegisterdUser.objects.filter(finish_mail = False) for asm_user in all_user_result: email = asm_user.student.email full_name = asm_user.student.username module_name = asm_use

我想在django user中创建一个cron作业,用于向用户发送电子邮件

all_user_result = AssesmentRegisterdUser.objects.filter(finish_mail = False)
for asm_user in all_user_result:
    email = asm_user.student.email
    full_name = asm_user.student.username
    module_name = asm_user.test.module_name
    test_finish_mail(to_email = email, full_name = full_name, module_name = module_name)
    asm_user.finish_mail = True
    asm_user.save()
当我在作业下尝试此代码时,它无法从我的数据库中检索(使用外键关系)
asm\u user.student.user.email
asm\u user.test.module\u name

注意:Cron作业正在处理静态数据


也许你应该发布模型。我的工作遵循以下方法:1-创建一个django管理命令2-在hash script中调用python manage.py命令\u name那么你是在告诉cron数据库查询内部不工作?您确定在使用python bashyes时所有用户结果都会有一些价值吗?注意:Cron作业使用的是静态数据。例如:email='example.com'…etc和asm\u user.finish\u mail=True也反映在db上