【问题标题】:Problem with moving static folders移动静态文件夹的问题
【发布时间】:2011-08-14 13:28:40
【问题描述】:

我在将 django 应用程序上传到 dotcloud 时遇到问题。我正在使用下面的代码将 django 的管理面板静态文件更改为 /static/admin_media,但是在部署时它给了我以下错误:

2011-08-14 13:22:35 [www.0] Traceback (most recent call last):
2011-08-14 13:22:35 [www.0]   File "./postinstall", line 23, in <module>
2011-08-14 13:22:35 [www.0]     os.symlink(mediadir, staticlink)
2011-08-14 13:22:35 [www.0] OSError: [Errno 2] No such file or directory

和代码:

import os
# To import anything under django.*, we must set this variable.
os.environ['DJANGO_SETTINGS_MODULE'] = 'kalvin.settings'
# Import the admin module. The media directory is right under it!
import django.contrib.admin
# Retrieve the absolute path of the admin module.
admindir = os.path.dirname(django.contrib.admin.__file__)
# Add /media behind it.
mediadir = os.path.join(admindir, 'media')
# Compute the path of the symlink under the static directory.
staticlink = os.path.join('static', 'admin_media')
# If the link already exists, delete it.
if os.path.islink(staticlink):
    os.unlink(staticlink)
# Install the correct link.
os.symlink(mediadir, staticlink)

【问题讨论】:

  • 请修正您的问题标题。技术列表(我们已经在标签中,顺便说一句)没有描述这个问题。

标签: python django dotcloud


【解决方案1】:

解决方案是this answer

我需要一个名为 static 的空文件夹,但 git 没有将它传输到服务器,因为它是空的。

在文件夹内创建.gitignore 解决了问题。

【讨论】:

    猜你喜欢
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-28
    • 2011-06-11
    • 2011-11-21
    • 2022-01-09
    • 1970-01-01
    相关资源
    最近更新 更多