Solution 1 :

Found the issue! it was the folder order. I had the static folder on the outside of my apps because I was treating it like the templates folder but I had to move it to an app for it to work. Thanks for the help tho!

Problem :

If anyone can help me on why my html wont link with my css that would be awesome! Thanks!
I’m using Django 3.0.2 to make a website for a resume and I have already rooted my static files and that didn’t seem to do anything. I have tried stopping and running my server multiple times as well as find solutions online but everyone is using an older version or their solutions don’t help.

HTML:

<head>
    {% load static %}
    <link rel="stylesheet" type="text/css" href="{% static '/base/styles.css' %}">
</head>
<body>
    this is a test
    <div class="container">
        <header>
            {% include 'navbar.html' %}
        </header>
    </div>
</body>

CSS:

body {
    background-color: rgb(82, 70, 70);
}

.container{
    background-color: rgb(128, 199, 172);
}

.navbar{
    background-color: rosybrown;
}

SETTINGS:

STATICFILES_DIR = [
    os.path.join(BASE_DIR, 'static'),
    '/pydir/mysite/static',
]

STATIC_ROOT = '/pydir/mysite/static'

STATIC_URL = '/static/'

and I made sure that staticfiles and admin where in the installed apps.

FOLDER STRUCTURE:

├───mysite
│   │   asgi.py
│   │   settings.py
│   │   urls.py
│   │   wsgi.py
│   │   __init__.py
│   │   
│   └───__pycache__
│           settings.cpython-37.pyc
│           urls.cpython-37.pyc
│           wsgi.cpython-37.pyc
│           __init__.cpython-37.pyc
│           
├───pages
│   │   admin.py
│   │   apps.py
│   │   models.py
│   │   tests.py
│   │   views.py
│   │   __init__.py
│   │   
│   ├───migrations
│   │       __init__.py
│   │       
│   └───__pycache__
│           views.cpython-37.pyc
│           __init__.cpython-37.pyc
│           
├───projects
│   │   admin.py
│   │   apps.py
│   │   models.py
│   │   tests.py
│   │   views.py
│   │   __init__.py
│   │   
│   ├───migrations
│   │   │   0001_initial.py
│   │   │   __init__.py
│   │   │   
│   │   └───__pycache__
│   │           0001_initial.cpython-37.pyc
│   │           __init__.cpython-37.pyc
│   │           
│   └───__pycache__
│           admin.cpython-37.pyc
│           models.cpython-37.pyc
│           __init__.cpython-37.pyc
│           
├───static
│   ├───base
│   │       styles.css
│   │       
│   └───images
└───templates
        home.html
        navbar.html

Comments

Comment posted by khaled hadjali

try to put the {% load static %} in the top of the file

Comment posted by Blake Hufford

tried moving it but still nothing :/

Comment posted by khaled hadjali

did u do the command python manage.py collectstatic

Comment posted by Blake Hufford

yeah, it created a folder named admin in my static folder and said that it copied 130 files to it. My css file isn’t in it tho so idk if I am supposed to put it in the new folder

Comment posted by dirkgroten

Where is your

By