Ask Your Question
0

askbot running without pictures and js

asked 2017-02-08 10:00:57 -0500

rosettas gravatar image

updated 2017-02-24 11:36:09 -0500

the askbot is running with uwsgi.

while the askbot run with python manage.py runserver, it is working fine.

but while it run from uwsgi, the all pictures and js lost.

seems the pictures and js location is like: <script type="text/javascript" src="/m/default/media/jslib/timeago.js?v=1"></script>.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-02-11 09:08:07 -0500

Evgeny gravatar image

updated 2017-02-11 09:09:20 -0500

Configure your web server to serve static files. For example, in nginx:

location /m/ { # url should be the same as STATIC_URL in settings.py in this case it's /m/
    alias /path/to/static/files/; #path should be the same as STATIC_ROOT in settings.py
    autoindex off;
    expires 30d;
}
edit flag offensive delete link more

Comments

Thanks! But I am still curious why "manage.py runserver" could handle the /m/ but uwsgi could not? And what is the reason to have /m/ instead of static which is the real folder name?

rosettas gravatar imagerosettas ( 2017-02-12 14:54:13 -0500 )edit

Because in production it's a lot more efficient to serve static files by a web-server such as nginx, rather than by a Python program. The `runserver` is meant only for the development and testing, so it should be serving from the media directories. The /m/ `STATIC_URL prefix can be replaced with anything else. Short url saves on bandwidth, even though a tiny bit.

Evgeny gravatar imageEvgeny ( 2017-02-12 17:08:01 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-02-08 10:00:57 -0500

Seen: 130 times

Last updated: Feb 11