2011-08-14 86 views
1

我在將django應用程序上傳到dotcloud時遇到問題。我使用下面的代碼以Django的管理面板靜態文件更改爲/靜態/ 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) 
+0

請修復您的問題標題。技術列表(我們已經在標籤中,btw)沒有描述這個問題。 –

回答

0

解決方案是this answer

我需要一個名爲static的空文件夾,但git沒有將它傳輸到服務器,因爲它是空的。

創建.gitignore裏面的文件夾修復了這個問題。