general03 general03 - 4 months ago 51
Python Question

Static files on Openshift with Django

I can't found my static files like css, js and picture. I get 404 error page.

In my settings django I have

STATIC_ROOT = '/var/lib/openshift/*id*/app-root/repo/*project*/*app*'
STATIC_URL = '/static/'


and my filesystem are

- project
- app
- wsgi.py
- static # I also tried to move this folder in wsgi folder
- css
- base.css
- ...


I tried to move the static folder in wsgi folder created before.
I also tried to move my static folder or wsgi folder in data folder of openshift without success.

I follow few help posts from Stackoverflow without found my answer



Can you help me to configure my static folder ?

Thanks

Answer

In the wsgi.py I have to have sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'])) os.environ['DJANGO_SETTINGS_MODULE' ] = 'project.settings.app' and in my settings.py STATIC_ROOT = os.path.join(os.getenv('OPENSHIFT_REPO_DIR'), 'wsgi/static', ) STATIC_URL = '/static/' And the filesystem of my website repo project ... wsgi static wsgi.py