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

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
rosettas's avatar
23
rosettas
asked 8 years ago
gopalraha's avatar
332
gopalraha
updated 8 years ago

Comments

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;
}

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 8 years ago, updated 8 years ago
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 (8 years ago)

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 (8 years ago)
see more comments