Django:“设置”对象没有属性“ LOGFILE”

时间:2020-02-29 02:08:30

标签: django attributeerror

这是我的代码

from datetime import datetime
from django.conf import settings


class Utils(object):

    def get_logs(self):
        try:
            with open(settings.LOGFILE, 'r') as fd:
                data_logs = fd.readlines()
            return data_logs
        except IOError:
            return []

    def write_log(self, content):
        date = datetime.now()
        with open(settings.LOGFILE, 'a+') as fd:
            fd.write("%s  :  %s\n" % (date.strftime("%b %d %Y %H:%M:%S"), content))

当我运行服务器时,Django给出错误Django: Settings' object has no attribute 'LOGFILE'。是什么原因造成的?

0 个答案:

没有答案