Jordan Harris
Jordan Harris

Reputation: 353

Django css isn't working, even though the css file is found

So in my html i have this link

<link href="/static/css/style.css" rel="stylesheet">

I already set up all my static files: settings.py:

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
    #'/var/www/static/',
]
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static')

urls.py:

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

I already ran python manage.py collectstatic

So when I load this page with the link, the bootstrap css loads and it doesn't say it can't find the style.css file, so I'm pretty sure its not an issue with my static directory because the files are registering and when it doesn't find the file it will say in the command shell as you load the page.

This is a snippet of what style.css looks like. I won't show you the whole thing cause it's long:

html,
body,
header,
.view {
height: 100%;
 }

.icon-1 {
  font-size: 75px;
} 

@media (max-width: 740px) {
html,
body,
header,
.view {
  height: 1000px;
}
}
@media (min-width: 800px) and (max-width: 850px) {
html,
body,
header,
.view {
  height: 600px;
}
}
@media (min-width: 800px) {
.music-margin-top {
   margin-top: 140% !important;
}

.music-just2{
  left: .4%;
}

.music-just4{
  left: .3%;
}

So basically none of my custom css is showing up, but the file seems to be found when the page is loaded. Also, if I put everything in the style.css into style brackets in my html file, it loads perfectly fine. Any ideas to what I'm doing wrong?

Upvotes: 2

Views: 3692

Answers (2)

Mokhtari Mokhtar
Mokhtari Mokhtar

Reputation: 1

Just BASE_DIR in your STATIC_ROOT is enough = os.path.join(BASE_DIR, 'static')

Upvotes: 0

Jordan Harris
Jordan Harris

Reputation: 353

So I just figured out that If I add the css to a file called style.min.css and link that, it works. Can anyone explain to me why this is?

Upvotes: 1

Related Questions