报错内容:AttributeError: ‘Settings‘ object has no attribute ‘GENERATED

    技术2022-07-11  106

    报错内容/ AttributeError: 'Settings' object has no attribute 'GENERATED_STATIC_HTML_DIR' 环境:django3.0.2

    # 源代码如下: # 写入静态文件,GENERATED_STATIC_HTML_DIR,这种导入方法是错的 file_path = os.path.join( settings.GENERATED_STATIC_HTML_DIR, 'goods/' + str(sku_id) + '.html' # goods/16.html ) with open(file_path, 'w') as f: f.write(sku_html_text)

    template = loader.get_template('index.html') html_data = template.render(context) #将文件写入 file_path = os.path.join(settings.GENERATED_STATIC_HTML_FILES_DIR,'index.html') with open(file_path,'w') as f: f.write(html_data)

    成功!

    总结: settings.GENERATED_STATIC_HTML_DIR,

    改为:settings.GENERATED_STATIC_HTML_FILES_DIR,

    Processed: 0.010, SQL: 9