【问题标题】:Problem to run a check in my database in django在 django 中检查我的数据库时出现问题
【发布时间】: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


【解决方案1】:

将 ship 模块添加到 settings.py 的 INSTALLED 部分

【讨论】:

  • 我从一开始就这样做了。
  • 你能提供你的settings.py吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-08
  • 2013-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多