0

I am unsure of what has happened, but i've followed a few guides that i've found around on the internet about serving media files through static folder (served from the $OPENSHIFT_DATA_DIR) by using mod_rewrite. The only problem now is, my admin files no longer get served and I'm struggling to fix it.

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

The above works fine for the /media/ files that are uploaded by my users however there is a huge problem when it comes to the admin files being served. They seem to have just literally stopped being served from /static/admin/.

Llanilek
  • 3,386
  • 5
  • 39
  • 65

2 Answers2

0

I've managed to get this working by adding a few commands into the build file. This will now copy all the admin files directly into /static/admin.

It doesn't seem as clean as it could be but will do for now until someone can provide an improvement on this subject.

if [ ! -d $OPENSHIFT_REPO_DIR/wsgi/static/admin ]; then
mkdir $OPENSHIFT_REPO_DIR/wsgi/static/admin
fi

cp $OPENSHIFT_GEAR_DIR/virtenv/lib/python2.6/site-packages/Django-1.4.1-py2.6.egg/django/contrib/admin/static/admin $OPENSHIFT_REPO_DIR/wsgi/static/
Llanilek
  • 3,386
  • 5
  • 39
  • 65
0

You should run the collectstatic command from django whenever you deploy. This will copy the necessary static files from all your apps to the proper directory.

I have a github example of django 1.6 that does this. It's a combination of setttings.py settings and a action_hook.

https://github.com/jfmatth/openshift-django16

HTH

YoFlynn
  • 84
  • 1
  • 6