I am trying to load a CSS file located in my static files onto an extended django html file. The {% load static %} works in the base.html template but does not work anywhere else. I’m not sure how to proceed
What’s making you think that the load static tag isn’t working? I don’t see where you have any static tags in that template where load static would even be used.
The load static tag does not load static files. It’s purpose is to allow you to use the static tag in your template.
What you want to look at here are the requests being made to the server. If you do a shift-refresh on the page, your server console should show requests for the static files in addition the requests for the page.
Examine the html that was rendered and sent to the browser. Examine the ancillary requests being made for that page in your console logs. Ensure you don’t have another base.html template that’s being loaded for that page. Verify that your css selectors are actually correct such that they would apply to the elements on your page.
That is not an accurate statement. The load static doesn’t directly affect the rendering, it just makes that tag library available for use. In this case it is irrelevent since he’s not using any static tags in his template.
Also, in the future, please do not post images of code or templates. If you’re going to post code, copy/paste it into the body of your message, surrounded by lines of three backtick - ` characters. This means you’ll have a line of ```, then your code (or template), then another line of ```.
In your extended html file after loading the static you have not linked the css file. Use this tag to link the css file <link rel="stylesheet" href="{% static 'styles/style.css' %}" /> in
It’s not necessary to do that since the style.css is (should be) loaded in the base template. If it’s loaded by the base, it does not need to be loaded in the template that extends the base.
I have same question. I load static in base.html but whenever i try to use it in child tempelate it require me to load it again in child tempelate base.html
That’s correct. That’s the proper and expected behavior.
Again, the {% load static %} tag doesn’t do anything in your template. It loads the definition for the static tag so that you can use {% static ... %} elsewhere in that template.