Chubak Chubak - 6 months ago 35
Python Question

django 404 when opening static folder

I have created a /static/ folder in my project's root and changed the settings thusly:

STATIC_URL = '/static/'

STATICFILES_DIR = [os.path.join(BASE_DIR, "static")]

But when I open my localhost/static, it produces a 404 error. Why is that?


For Django 1.3+:


    os.path.join(BASE_DIR, "static")

STATIC_ROOT = path.join(TOP_DIR, 'staticfiles')
STATIC_URL = '/static/'

For apache:

Alias /static /var/my/site/static
<Directory /var/my/site/static>
        Require all granted