【发布时间】:2021-06-02 04:48:30
【问题描述】:
我创建了一个名为 Certs 的模型,模型已注册并显示在管理页面中,但是我试图调用它来运行检查并尝试执行任务,但我收到错误:没有名为“ships”的模块,
这是我项目的结构(注意我是在reminders.py中写代码):
这里是我的代码:
from django.core.mail import send_mail
from ships.models import Certs
from datetime import datetime, timedelta
b = Certs.objects.count()
def notifications():
for dates in range(b):
if Certs.exp_date[b] <= datetime.datetime.now() - timedelta(days=30):
send_mail(subject='Test',message='This is a reminder where you will be reminded about expiring certifications', recipient_list=['info@intermaritime.org'])
非常感谢
【问题讨论】:
-
关于文件设置,py,在 INSTALLED_APPS 下尝试包含 'ships.apps.shipsConfig'
标签: django function model task