1

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)
4

1 に答える 1

0

解決策はこの回答です。

という名前の空のフォルダーが必要でしたが、空だったため、staticgit はそれをサーバーに転送しませんでした。

フォルダ内に作成する.gitignoreと、問題が修正されました。

于 2011-08-14T13:38:34.197 に答える