First time here? Check out the FAQ!

images and stylesheets not found

Django 1.4.5
Postgres 9.2
askbot-devel (cloned from github)
DEBUG = True

When I test things with runserver, everything looks great. However, using the base example from the docs to try and get apache to serve the site, none of the images or stylesheets are found. The page otherwise loads fine.

The following is shown in the logs:

[21/May/2013:14:55:41 -0400] "GET /m/default/media/style/style.css?v=1 HTTP/1.1" 404 21420
[21/May/2013:14:55:41 -0400] "GET /m/default/media/js/modernizr.custom.js?v=1 HTTP/1.1" 404 21441
[21/May/2013:14:55:41 -0400] "GET /m/default/media/bootstrap/css/bootstrap.css?v=1 HTTP/1.1" 404 21456
[21/May/2013:14:55:41 -0400] "GET /m/default/media/js/jquery-1.7.2.min.js?v=1 HTTP/1.1" 404 21441
[21/May/2013:14:55:41 -0400] "GET /m/default/media/bootstrap/js/bootstrap.js?v=1 HTTP/1.1" 404 21450
[21/May/2013:14:55:41 -0400] "GET /m/default/media/js/jquery.history.js?v=1 HTTP/1.1" 404 21435
[21/May/2013:14:55:41 -0400] "GET /m/default/media/js/utils.js?v=1 HTTP/1.1" 404 21408
[21/May/2013:14:55:41 -0400] "GET /m/default/media/js/live_search.js?v=1 HTTP/1.1" 404 21426
[21/May/2013:14:55:41 -0400] "GET /m/default/media/js/editor.js?v=1 HTTP/1.1" 404 21411
[21/May/2013:14:55:41 -0400] "GET /m/default/media/images/cc-by-sa.png?v=1 HTTP/1.1" 404 21432
[21/May/2013:14:55:41 -0400] "GET /m/default/media/js/tag_selector.js?v=1 HTTP/1.1" 404 21429
[21/May/2013:14:55:42 -0400] "GET /m/default/media/images/favicon.gif?v=1 HTTP/1.1" 404 21429

I saw the similar Question 8453 which has an answer for adding an additional 2 lines to alias the /m/ urls, so I tried that (pointing to my virtualenv and repo fork respectively) and it didn't work because /askbot/skins/ has no static media in it.

$ ls /home/user/askbot-devel/askbot/skins/  __init__.pyc  loaders.pyc  README  utils.pyc

I finally hardcoded default in the alias and edited those two apache conf lines to read:

 Alias /m/admin/ /home/user/.virtualenvs/askbot/lib/python2.6/site-packages/django/contrib/admin/media/
 Alias /m/default/ /home/user/downloads/askbot-devel/askbot/

That doesn't feel right to me hardcoding the default in there even though everything now works. What is that alias supposed to be pointing to exactly?

kporangehat's avatar
asked 2013-05-21 15:31:02 -0500
edit flag offensive 0 remove flag close merge delete


add a comment see more comments

1 Answer


Configure Apache to serve the static files directly using the Alias directive. Probably Alias directives in the sample Apache config are wrong.

In production any static file requests should not be touching django application at all.

Evgeny's avatar
answered 2013-05-21 15:33:16 -0500, updated 2013-05-21 15:34:38 -0500
edit flag offensive 0 remove flag delete link


Ok so it looks like in that sample Apache config this line

Alias /static/ /path/to/django-project/static/

should be:

Alias /m/ /path/to/django-project/static/

Since the document root is already /path/to/django-project, /static/ will map to the correct place it seems.

kporangehat's avatar kporangehat (2013-05-21 15:48:17 -0500) edit

Hit "shift+enter" to make a new line, sorry, this is a bit hidden and you can indent the code blocks like in markdown.

Evgeny's avatar Evgeny (2013-05-21 15:51:57 -0500) edit

argh sorry. I know shift-enter now but it still gets me every time. Do the plain text comments support any markdown formatting like backticks?

kporangehat's avatar kporangehat (2013-05-21 15:56:56 -0500) edit

This site is a bit outdated and I don't remember. In the latest version you can use the same editor in the comments as for questions and answers with all the functions.

Evgeny's avatar Evgeny (2013-05-21 15:59:39 -0500) edit

Thanks, updated the documentation in the repo.

Evgeny's avatar Evgeny (2013-05-21 16:16:59 -0500) edit
add a comment see more comments