You will have to understand the concept of overriding of CSS.
If a component is loading with “!important” in the parent CSS such as:
background-color: #5f788a!important;
instead of just:
background-color: #5f788a;
In such cases, you will not be able to override it in your custom/child CSS because !important declares it important and can’t be overriddendirectly.
However, you can still override it in the custom CSS by applying !important at the end of the value of the component just the way I did above.
You may be confused about Why did it work in Corey’s CSS ?
Answer: The version of bootstrap Corey used in the tutorial was not rendering the background-color with the term !important at the end and hence he was able to override it directly. But nowadays, bootstrap color classes render with background-color: #5f788a!important; and hence can’t be overridden directly.
Second reason: for a division to have a border, header, and content with margins applied, you either use a default card class or you implement one on your own — found in this line, which also didn’t work.
<article class="media content-section">
Third reason: obvious enough, the background colors are different. In your code, it’s pure white, which is what bootstrap’s default comes with. If the custom sheet is applied, the background color will then look darker.
Here’s what I’ll suggest you do:
Go to your HTML or settings.py (if you used {% load static %}) file and check whether your static or import paths are correct
Go through the video one more time and make sure you have no typos.
As a matter of fact, the javascript files ARE necessary. If you don’t include them, things like dropdowns and modals won’t work properly.
Problem :
So I’m going through Corey Schafer’s Django series, and I’m at the part where he is building the HTML template for the website and for some reason it isn’t formatting correctly. I downloaded his repository and re-ran his code and still got the same error? The only difference that I can think of is that he is using Django 2.1 and I’m using Django 3.0 but that shouldn’t be it.
(4) Close your server, and clear your browser from everything (cookies included)
Comments
Comment posted by crimsonpython24
I’m unclear on which image is it that you included, but I’ll strongly recommend you include both: one for how it should look like, and one for how it turns out to be.
Comment posted by Lemon.py
As crimson said, it would help to have a picture of what it’s supposed to look like.
Comment posted by Achuth Varghese
check if the custom css blog/main.css is being loaded properly in your terminal after the server has been run/re-run. You should see
Comment posted by Achuth Varghese
sorry, i meant
Comment posted by Al-Baraa El-Hag
@crimsonpython24 I added the picture of what it should be like
Comment posted by Al-Baraa El-Hag
I first wrote my own code, and ran into this problem. So I downloaded Corey’s code and ran it as is, and it also came up so I don’t believe it is a typo issue. An upvoted commented on youtube said this:
Comment posted by crimsonpython24
I don’t think that will be the problem: a direct translation will be “put your custom style behind the bootstrap ones”, which you already did. The next thing I’d like you to do for me is to check whether you get the css file successfully in your html document.
Comment posted by Al-Baraa El-Hag
I do, the link to
Comment posted by crimsonpython24
But one of the comments above read
Comment posted by Al-Baraa El-Hag
Oh wow, that was it! I cleared the cookies and reran Corey’s code again and it worked. If you edit your post to include that information, I will accept the answer. But my own code isn’t working right, so I’m going to have to compare it to Cody’s to find the problem. I will post an edit when I do because, at least on youtube, it seems I’m not the only one that has the problem.