简体   繁体   中英

How should I link base.css with base.html file in Django?

I'm trying to link my base.css to base.html file. As I'm doing this but it doesn't reflect any changes. If it is possible, what'll be the correct code?

I use header & footer tag in the base.html file and there are no. of different properties I'm implementing in the project. So the separate CSS file would be better rather than using inline styling or internal style sheet. But it isn't working.

syntax of code used:

`{% load static %}
  <html>
  <head>
    <link rel = 'stylesheet' href = '{% static 'css/base.css' %}'>
  </head>
  <header>
    ......
    ......
  </header>
  {% block content %}
  {% endblock %}
  <footer>....
  </footer>
  </html>'

Also, when I tried to make a separate .css file for base.html. It didn't work. So I'm confused now. It seems like you can't link two template tag files - base.html (Common Header & Footer) for every web pages & base.css for styling of every web pages.

Using <link rel = 'stylesheet' href = '{% static 'css/base.css' %}'> is the correct way of linking a css file.

Assuming I am reading your question correctly, you may be having an issue with caching in your browser if certain effects are not appearing. I would recommend starting with disabling your cache in chrome for development. Right click > inspect element > Network > "Disable Cache"

If this is not the issue you are having then you may need to rephrase your question to explain what is not working correctly.

Your CSS is necessary in base.css ? If not one solution is in admin.py add class Media: css = { 'all': ('css/bass.css',) }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM