Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django staticfiles

I'm struggling getting staticfiles (CSS) to work on my Django site deployed to Openshift. I can workaround this by putting style info in the HTML templates, but the Django admin site stylesheets still will not load. Everything works locally, including with debug off.

Openshift stores staticfilesunder repo/ -> wsgi/ -> static/, where the main project directory is also under wsgi/.

Here are the relevant parts of settings.py:

ON_OPENSHIFT = True if 'OPENSHIFT_REPO_DIR' in os.environ else False
PROJECT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), os.pardir)

if ON_OPENSHIFT:
    STATIC_ROOT = os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi', 'static')
else:
    STATIC_ROOT = ''

STATIC_URL = '/static/'

if ON_OPENSHIFT:
    STATICFILES_DIRS = (os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi', 'static'))
else:
    STATICFILES_DIRS = [os.path.join(PROJECT_DIR, 'static')]

I have a script that runs the following when deploying:

cd $OPENSHIFT_REPO_DIR/wsgi/squadron
python manage.py collectstatic --noinput

I'm using Python 3.3 and Django 1.6, and referencing the following guides: 1 and 2 from the docs.

What am I doing wrong? I don't get an error message, just no stylesheets, either my own, or on Django admin. When I use SCP, I can verify my stylesheet is in the correct Openshift directory.

like image 889
Turtles Are Cute Avatar asked Sep 04 '26 05:09

Turtles Are Cute


1 Answers

This is the best source to read when you are trying to get OpenShift working with Django.

http://appsembler.com/blog/django-deployment-using-openshift/

Some of this will be changing (for the better) with upcoming releases but this should help for now.

like image 138
TheSteve0 Avatar answered Sep 06 '26 19:09

TheSteve0