First time here? Check out the FAQ!
1

askbot running without pictures and js

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>.

rosettas's avatar
23
rosettas
asked 2017-02-08 10:00:57 -0600
gopalraha's avatar
332
gopalraha
updated 2017-02-24 11:36:09 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

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;
}
Evgeny's avatar
13.2k
Evgeny
answered 2017-02-11 09:08:07 -0600, updated 2017-02-11 09:09:20 -0600
edit flag offensive 0 remove flag delete link

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's avatar rosettas (2017-02-12 14:54:13 -0600) 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's avatar Evgeny (2017-02-12 17:08:01 -0600) edit
add a comment see more comments