'Django 404 error-page not found & No CSS renders

New-ish coder and first time stack overflow poster. I've made a django project with 3 pages. Sometimes no pages are found, sometimes the index page loads without 404 error but I can't link to other pages and the css files I've pointed it to doesn't render.

Errors I'm getting is:

404 error

I have slept on the problem, looked up file formats to make sure my project and app url.py is correct. added app to settings. imported correct classes. I have also tried clearing my browser data on chrome and using a different browser.

If anyone could take a look at my small project on github that would be amazing. https://github.com/Connell-L/portfolio_website is the link or if anyone wants me to post code files on codepen or something I'm more than happy to do it.

Edit: https://github.com/Connell-L/portfolio_website/tree/branch1 it's here sorry lol



Solution 1:[1]

You need to add STATICFILES_DIRS and STATIC_ROOT to your project settings.py

like this:

 BASE_DIR = Path(__file__).resolve().parent. 

the above line of code has to be at the bigining of your settings.py file

STATIC_URL = "static/"
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static")
]
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ismaili Mohamedi