2

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?

2 Answers 2

1

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?

Sign up to request clarification or add additional context in comments.

2 Comments

You have static url as /static/ which means all your static files are inside static directory. Now what I guess, you have a folder called css inside your static directory and inside css you have your required file. Hence your desired path is static/css/style.css
The reason is that you have another CSS file with the same name style.css probably in the static directory of another app, making the two to be clashing with each other. So by renaming one of the two will solve the problem as you already saw. But the point here is that it don't have to be style.min.css, any renaming will work.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.