Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have extensively searched for a solution to my problem; however, due to the lack of success I decided to post a question.

In short: I have created an OpenShift app/build based on this repo (in combination with a DIY 0.1 cartridge):

The (apparently quite common) problem I have is that I can not get access to static files working; I have tried a lot.

These are a few things of all I have tried so far (and I am assuming that the wsgi for this build is /app/ (?)):

    • I tried to set this to pretty much all possible places in my repo while placing a static folder with the corresponding static files in there, e.g.
      • /static
      • /app/static
      • /app/app/static
      • etc.
    • I kept this set to '/static/' as this is just the URL prefix if I'm not completely wrong
    • set this to the absolute path on the file system, there shouldn't be much that could be wrong with that.
  • .htaccess tried a few things with .htaccess rewrites as well but mildly in the wild as I am not perfectly sure how communication flow between Django and Apache works/how Django passes static requests on to Apache and where on the file system/in the repo Apache's root dir is (?)

I can give more info if needed but that's the essential so far.

It should be noted that this seems to be a unique case with this build as I don't have problems when i create an app based on the fully supported Python26/Django cartridge.

Any suggestions whatsoever would be greatly appreciated..!


share|improve this question

This article "Serving Django Static Assets on OpenShift", seems to suggest a solution.

share|improve this answer

Static files should be served directly by Apache, not by Django. The process is as follows (assuming your codebase is /srv/code/project):

  • Place your static files in /srv/code/project/app/static/ (where app is listed in INSTALLED_APPS)
  • If you need static files not related to an app (or common to many), define a directory in STATICFILES_DIRS (usually within your codebase, e.g. /srv/code/project/static/) and place the files there.
  • Define a STATIC_ROOT outside your codebase, e.g. /srv/www/ This is going to act as a cache of all static files.
  • Whenever deploying a new version of the project, run python collectstatic. This will go through all the static directories and copy the files to STATIC_ROOT.
  • Configure Apache to serve all requests under /static/ from the STATIC_ROOT.
share|improve this answer
Great, thanks for your reply; however, that's pretty much as far as I had already gotten and your last step (configuring Apache to serve from the directory I define in STATIC_ROOT) is where I get stuck on OpenShift as I can't find a way to configure Apache (centrally or on sub-branches of the FS through .htaccess). If there still is a way I'd be very curious. (++ if I were able to vote yet!) – bossi Mar 5 '13 at 13:01
This answer doesn't seem to address OpenShift at all. – larsks Sep 5 '13 at 15:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.