2

我的静态文件设置看起来像

STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    '/var/lib/openshift/<app_id>/app-root/runtime/repo/static',
)

在我的index.html我试图让他们成为

{% block javascript %}
        <!--script type="text/javascript" src="../static/js/bootstrap.js"></script-->
        <script type="text/javascript" src="/static/js/jquery.js"></script>
        <script type="text/javascript" src="../static/js/slides.js"></script>
    {% endblock %}

        {% block css %}
            <link rel="stylesheet" href="../static/css/bootstrap.css" type="text/css" media="screen" title="no title" charset="utf-8">
            <link rel="stylesheet" href="../static/css/index.css" type="text/css" media="screen" title="no title" charset="utf-8">
        {% endblock %}

当我尝试加载页面时,我HTTP 500在加载资源和日志中看到

Traceback (most recent call last):
  File "/opt/rh/python27/root/usr/lib64/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/contrib/staticfiles/handlers.py", line 68, in __call__
    return super(StaticFilesHandler, self).__call__(environ, start_response)
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/contrib/staticfiles/handlers.py", line 58, in get_response
    return self.serve(request)
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/contrib/staticfiles/handlers.py", line 51, in serve
    return serve(request, self.file_path(request.path), insecure=True)
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/contrib/staticfiles/views.py", line 35, in serve
    absolute_path = finders.find(normalized_path)
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/contrib/staticfiles/finders.py", line 237, in find
    for finder in get_finders():
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/contrib/staticfiles/finders.py", line 252, in get_finders
    yield get_finder(finder_path)
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/utils/functional.py", line 27, in wrapper
    result = func(*args)
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/contrib/staticfiles/finders.py", line 274, in _get_finder
    return Finder()
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python/virtenv/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/contrib/staticfiles/finders.py", line 59, in __init__
    if os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root):
  File "/var/lib/openshift/51d9d4d3e0b8cd1e6d0000fd/python//virtenv/lib64/python2.7/posixpath.py", line 356, in abspath
    cwd = os.getcwd()
OSError: [Errno 2] No such file or directory

我在这里想念什么?

我该如何解决这个问题?

4

1 回答 1

1

解决问题/后追加static

STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    '/var/lib/openshift/<app_id>/app-root/runtime/repo/static/',
)
于 2013-09-08T18:16:53.210 回答