Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serving Django static files in OpenShift

According to the March 2014 blog post, OpenShift now got rid of some directories like wsgi/, wsgi/static/, data/ and libs/.

Given I used wsgi/static for this purpose, how I am supposed to serve django static files from now on?

like image 283
giallu Avatar asked Mar 26 '14 11:03

giallu


People also ask

How do I serve static files in Django?

django.contrib.staticfiles provides a convenience management command for gathering static files in a single directory so you can serve them easily. Set the STATIC_ROOT setting to the directory from which you’d like to serve these files, for example:

How do I add static assets to a Django project?

Your project will probably also have static assets that aren’t tied to a particular app. In addition to using a static/ directory inside your apps, you can define a list of directories ( STATICFILES_DIRS) in your settings file where Django will also look for static files.

How do I add a static base to a Django template?

There are two main ways to structure templates in a Django project as outlined in this tutorial. Let's assume we are using a templates/base.html file for a Blog project. To add our static base.css file to it we'd start by adding {% load static %} at the top of the file and then use the {% static %} tag with the path to it.

How do I add a CSS file to a Django app?

By default, Django will look within each app for a static directory containing static files. So if one of your apps was called blog and you wanted to add a CSS file to it called base.css, you need to first create a new directory called blog/static and then add the file within it so the location would be blog/static/style.css.


1 Answers

According to openshift.conf.erb, it seems like it checks if you have a $OPENSHIFT_REPO_DIR/wsgi/static directory and it keeps it working. I haven't verified that this works, but it looks like it should.

like image 50
errno Avatar answered Sep 29 '22 02:09

errno