python - Second stylesheet in child template / Overriding style sheets -


i have website i'm putting python , django. have template html page, speakers.html, extends base.html. base.html has stylesheet base.css.

speakers.html displaying base.css styling should be, problem want speakers.html have additional styling stylesheet, speakers.css.

i've been trying figure out speaker.css doesn't seem applied, infact i've noticed in cmd output file speaker.css isn't being loaded @ all.

i tried putting in block, code see below.. had repeat {% load static %} rid of error expecting endblock doesn't seem have made difference.

base.html

<!doctype html> <html lang="en">  <head>     <title>base.html</title>     {% load static %}     <link rel="stylesheet"  type="text/css" href="{% static "css/base.css" %}" />     {% block additionalcss %}{% endblock %} </head>  <body>  ...ect 

speakers.html

<!-- extending works --> {% extends "base.html" %}     <!-- i'm trying load additional stylesheet --> {% block additionalcss %} {% load static %} <link rel="stylesheet"  type="text/css" href="{% static "css/speakers.css" %}" /> {% endblock %}  {% block currentpage_content %} <h2>guest speakers @ event</h2>  <p> text red if speakers.css applying </p> ...ect 

for testing purposes i've put following rule in speakers.css:

* { color: red; } 

so reason text on speakers.html should red if working.

try using blocks in templates.

something like:

base.html

<!doctype html> <html lang="en">  <head>     <title>base.html</title>     {% load static %}      {% block css %}{% endblock %}     <link rel="stylesheet"  type="text/css" href="{% static "css/base.css" %}" /> </head>  <body>  ...ect 

speakers.html

<!-- extending works --> {% extends "base.html" %}   {% block css %} {% load static %} <link rel="stylesheet"  type="text/css" href="{% static "css/speakers.css" %}" /> {% endblock %}  {% block currentpage_content %} <h2>guest speakers @ event</h2>  <p> text red if speakers.css applying </p> ...ect 

by defining blocks in parents , specifying them in children css files inserted template.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -