Giter Club home page Giter Club logo

Comments (14)

bparees avatar bparees commented on June 12, 2024

@rhcarvalho or @GrahamDumpleton can you help here?

from django-ex.

PI-Victor avatar PI-Victor commented on June 12, 2024

there's a link in that settings file that tells you how to deal with them,
for what i can tell there's no static directory in this projects because we have everything (css/js) in the template file

from django-ex.

PI-Victor avatar PI-Victor commented on June 12, 2024

and the link: https://docs.djangoproject.com/en/1.8/howto/static-files/

from django-ex.

general03 avatar general03 commented on June 12, 2024

Thanks @PI-Victor but you can imagine that I already done that.
My project works fine in local.
I tried several configurations and you can find more informations on my post : http://stackoverflow.com/questions/37845189/static-files-on-openshift-with-django
Thanks

from django-ex.

rhcarvalho avatar rhcarvalho commented on June 12, 2024

Hi @general03, looking at your SO post, I think you're working with OpenShift v2, where you have cartridges and so on (current OpenShift Online offering).
This example repository is meant for use with OpenShift v3. Doesn't mean you get no help :)

When you run Django in production (debug=False), you need to handle serving static files by some other means.

  • One way to do it is to setup a HTTP server like httpd or nginx.
  • Or use a pure-Python solution like this repo is configured to use WhiteNoise.

Looking at the implementation for the Python Cartridge, there's indeed an option to place files in $OPENSHIFT_REPO_DIR/wsgi/static:

<% #Backward compatibilty with wsgi/static/ directory
  if $SAFE!=2 && (File.directory?("#{ENV['OPENSHIFT_REPO_DIR']}wsgi/static") || File.symlink?("#{ENV['OPENSHIFT_REPO_DIR']}wsgi/static"))
    %><%= "Alias /static #{ENV['OPENSHIFT_REPO_DIR']}wsgi/static" %><%
  end
%>

So I suspect if you drop your static files in wsgi/static in your project repository it should work.

Definitely there must be some official documentation for that, @bparees any pointers?

from django-ex.

bparees avatar bparees commented on June 12, 2024

@rhcarvalho good catch. I can't seem to dig up any useful v2 python docs at the moment, but maybe @dinhxuanvu has a pointer.

from django-ex.

dinhxuanvu avatar dinhxuanvu commented on June 12, 2024

It doesn't look like we have an official document for this unfortunately or at least I couldn't find it anywhere. However, @rhcarvalho comment is correct regarding where to put static files $OPENSHIFT_REPO_DIR/wsgi/static. So his advice is the way to go.

Also, I found this post that looks useful. Please take a look: StackOverflow

Thanks.

from django-ex.

jfmatth avatar jfmatth commented on June 12, 2024

If you need a v2 version for django, try mine :)

https://github.com/jfmatth/openshift-django

from django-ex.

dinhxuanvu avatar dinhxuanvu commented on June 12, 2024

We do have a Django example for V2 which is https://github.com/openshift/django-example

from django-ex.

dinhxuanvu avatar dinhxuanvu commented on June 12, 2024

@jfmatth Sorry pal :D... I couldn't resist stealing your thunder :P...

from django-ex.

jfmatth avatar jfmatth commented on June 12, 2024

No worries, it's all free open source anyway, that's the way we do it.

But if ur at summit today, you can buy me a drink :)
On Jun 30, 2016 11:26 AM, "Vu Dinh" [email protected] wrote:

@jfmatth https://github.com/jfmatth Sorry pal :D... I couldn't resist
stealing your thunder :P...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#48 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AARpsg5RzugTvi8nuMb3jZ0v6bXLlM5sks5qRApKgaJpZM4JA1W5
.

from django-ex.

dinhxuanvu avatar dinhxuanvu commented on June 12, 2024

Haha. Sorry, I'm not at the Summit this year but next year when Summit is back in Boston, I owe you one :D.

from django-ex.

general03 avatar general03 commented on June 12, 2024

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

from django-ex.

jfmatth avatar jfmatth commented on June 12, 2024

You should checkout my repo, those changes aren't required :).

good luck

from django-ex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.