javascriptdjangodjango-static

Django - Is My Static File in the Wrong Place?


I'm creating a project for a weather app with Django, and I think my Javascript file is in the wrong place. I have it in a static folder. But I'm getting the console error GET http://127.0.0.1:8000/static/capstone/capstone.js net::ERR_ABORTED 404 (Not Found)

Here is how my project files are set up. Is this correct?

In settings.py I also have:

STATIC_URL = '/static/'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

enter image description here


Solution

  • make a new folder capstone and move your capstone.js to it.
    cause by default Django uses a static folder within an app, so in your case, you're visiting http://localhost:8000/static/capstone/capstone.js but the actual link is http://localhost:8000/static/capstone.js