【发布时间】:2019-11-17 09:28:27
【问题描述】:
我的问题是静态文件(img,样式)。我的代码运行良好,静态文件没有错误,并且在我运行服务器时出现图像,但是当我制作(debug = False)时,图像和样式消失了我在 Linux 服务器 ubuntu 上运行我的代码.... 怎么办我让静态文件显示为 (debug=false)?
in settings.py that is my code
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'music/templates/'),
)
在我的 html 文件中,图像标签是这样的:
<img src="{% static 'music/login.jpg' %}" width="300" height="300">
【问题讨论】:
-
当 debug 设置为 False 时,静态文件应用程序被禁用...我建议您阅读 docs.djangoproject.com/en/2.2/howto/static-files 和链接了几次的页面 docs.djangoproject.com/en/2.2/howto/static-files/deployment
-
您是否使用网络服务器(apache 或 nginx)来为您的应用程序提供服务?
-
没有...我使用 linux 服务器 ...Iain Shelvington
标签: django python-2.7 django-templates