找不到Django和OpenShift静态文件 [英] Django and OpenShift static files can't be found
问题描述
So I followed this tutorial: https://github.com/rancavil/django-openshift-quickstart/wiki/Tutorial-How-create-an-application-with-Django-1.6-on-Openshift
,我尝试将静态图片添加到默认的home.html页面,但找不到它.
and I tried to add a static image to the default home.html page and it just won't find it.
HTML:
{% load static %}
<html>
<head>
</head>
<body>
<img src="{% static 'Logo_Trans.png' %}">
<div class="left"></div>
<div class="right">
<p>is coming soon</p>
</div>
</body>
</html>
所有其他文件均在给定的存储库中列出.
All other files are as listed in the repo given.
推荐答案
我发现了问题.静态文件在部署时可以正常运行,但在调试模式下则不能正常运行.要解决此问题,只需在settings.py
I've found the problem. The static files were serving properly when deployed but not when in debug mode. To fix this just add the STATICFILES_DIR variable in settings.py
查找:
if ON_OPENSHIFT:
DEBUG = False
else:
DEBUG = True
添加:
if ON_OPENSHIFT:
DEBUG = False
else:
DEBUG = True
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),
'/var/www/static/',)
Openshift是一项非常好的服务,但是肯定需要更新Django的文档/示例.他们的示例程序仍然运行django 1.4.希望这对遇到此问题的其他人有所帮助.
Openshift is a very good service but definitely needs to update their docs/examples for django. Their sample program still runs django 1.4. Hope this helps anyone else that runs into this problem.
这篇关于找不到Django和OpenShift静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!