Chubak Chubak - 1 year ago 112
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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download