openshift上部署django程序时静态文件的处理方法


发布时间:2015年6月23日 17点16分

1.move “media”  directory to the “static” directory,like this “/static/media”

2.edit settings.py change MEDIA_ROOT to this

MEDIA_ROOT = os.environ.get(‘OPENSHIFT_REPO_DIR’, ”)+’/wsgi/static/media’

3.creat .htaccess under “wsgi” directory ,edit like this

RewriteEngine On
RewriteRule ^application/media/(.+)$ /static/media/$1 [L]

4.push your application and enjoy!