开发者

Problem with moving static folders

I have a problem with uploading a django app to dotcloud. I'm using the code below to change django's admin panel static files to /static/admin_media, but it gives me the following error when deploying:

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

and the code:

import os
# To import anything under django.*, we must set this 开发者_如何学Cvariable.
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)


The solution is this answer.

I needed an empty folder named static, but git didn't transfer it to the server because it was empty.

Creating .gitignore inside the folder fixed the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜