login community faq

Hello, I'm deploying my first django app, so please bear with me :)

I am encountering a 404 error (NGINX) when attempting to serve static media from within my app.

Per these instructions: http://docs.webfaction.com/software/django/config.html#serving-django-static-media

Here is my settings.py:

1
2
3
4
5
6
7
==============================================
STATIC_ROOT = 'home/austinrivas/webapps/static_media/'

STATIC_URL = 'http://austinrivas.webfactional.com/static/'

ADMIN_MEDIA_PREFIX = 'http://austinrivas.webfactional.com/static/admin/'
===============================================

I then executed python2.7 manage.py collectstatic

Now blog->myproject contains a dircetory called 'home' which appears to be an exact duplicate of my file structure leading up to the static files ( which I suppose is the expected result )

Obviously I receive 404 errors when attempting to retrieve any static files.

I think a symlink might do the trick, but I am hesitant to employ that because it shoots all of my attempts to decouple this application right in the foot.

Any help would be appreciated, Austin

asked Nov 17 '11 at 19:33

Austin%20Rivas's gravatar image

Austin Rivas
132

edited Nov 17 '11 at 22:13

ryans's gravatar image

ryans ♦♦
29461420

I apologize for the format errors, something weird happened when I pasted it over :(

(Nov 17 '11 at 22:07) Austin Rivas Austin%20Rivas's gravatar image

no worries - we fixed the formatting and are now looking into it.

(Nov 17 '11 at 22:13) ryans ♦♦ ryans's gravatar image

The problem is that you used:

1
STATIC_ROOT = 'home/austinrivas/webapps/static_media/'

instead of

1
STATIC_ROOT = '/home/austinrivas/webapps/static_media/'

The first one is a relative path, which explains why the manage.py collectstatic command created a new "home" directory in the current directory with a new filepath leading up to your static files. That's not normal.

Instead, just delete that "home" directory, fix STATIC_ROOT, and then run python2.7 manage.py collectstatic again. This time your static files should be placed in the correct location, which is /home/austinrivas/webapps/static_media/ .

Hope that helps!

answered Nov 17 '11 at 22:23

ryans's gravatar image

ryans ♦♦
29461420

1

Gracias, That solved it right off the bat. I would vote you up but I don't have enough rep yet :(

(Nov 18 '11 at 13:05) Austin Rivas Austin%20Rivas's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×653
×94
×73
×19

Asked: Nov 17 '11 at 19:33

Seen: 892 times

Last updated: Nov 18 '11 at 13:05

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited