Frage

I created an app locally with the django development server and now want to host it on the web.

I uploaded and installed everything on a server with python 2.7, django 1.4.5 and flup. Everything works fine until I try to use any static files. When my site tries to open a textfile it says: "No such file or directory" although the file definitely is in that folder.

Even weirder is that the server admin told me that his logs show the site isn't even looking in the directory it tells me, so the error message is "lying" about the path it is searching in.

Is there anything I have to do differently now that I want to host my program? On the development server it worked perfectly fine and now even after I tried every path combination in settings.py I could think of it won't work.

How do I get Django to serve static files on a production server?

EDIT:

When I try to visit http://ulli.cepheus.uberspace.de/fcgi-bin/mysite/polls/4/

I get the following error message but if you look at that link the textfile is clearly there.

IOError at /polls/4/

[Errno 2] No such file or directory: 'http://ulli.cepheus.uberspace.de/static/m.txt'

Stack Overflow doesnt let me post my settings.py or anything because there are too many links in it... how can I show it to you?

War es hilfreich?

Lösung

Have you tried to run

python manage.py collectstatic -l

More information on the staticfiles app can be found here.

Without more information, the best we can do is give you a link to read the documentation and you tell us what you've tried and what you haven't tried. If everything else is set up correctly, the running the command I gave you above should resolve one of the specific causes of your problem.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top