Search code examples
openshiftdjango-1.7paas

OpenShift repo not included in path


I started a Django 1.7 OpenShift instance. When I have python print all of the paths from sys.path I do not see OPENSHIFT_REPO_DIR (/var/lib/openshift/xxxxx/app-root/runtime/repo).

When I use https://github.com/jfmatth/openshift-django17 to create a project I do see OPENSHIFT_REPO_DIR in the path.

Looking through the example app above I don't see anywhere that this is specifically added to the path. What am I missing?

To clarify: I have to add the following to my wsgi.py:

import os
import sys
ON_PASS = 'OPENSHIFT_REPO_DIR' in os.environ
if ON_PASS:
    x = os.path.abspath(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'mysite'))
    sys.path.insert(1, x)
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

OPENSHIFT_REPO_DIR is not in my path as I would expect. When I used the example git above, I did not have to add anything to the path.


Solution

  • This issue appears to be caused by trying to use the standard file structure layout that django produces when you use startproject. Openshift appears to need a flatter file structure. As soon as I moved wsgi up to a sibling of mysite it resolved the issue.