I am working on a project where I need to have different styles for 
different templates.
I have a base.html template which gets extended in other templates.
Following is the snippet:
base.html
{% load static %}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Recommendation</title>
    <link rel="stylesheet" type="text/css" href="{% static 
'main_app/main.css' %}">
  </head>
  <body>
    <div class="sexy">
    {% block css%}

    {% endblock%}
    {% block nav %}
      <ul id='nav'>
        <li>{% block nav-help %} <a href="{% url 'help' %}">Help</a> {% 
endblock %}</li>
        <li>{% block nav-index %} <a href="{% url 'index' %}">Home</a> {% 
endblock %}</li>
        <li>{% block nav-query %} <a href="{% url 'query' %}">Query</a> {% 
endblock %}</li>
      </ul>
    {% endblock %}
    </div>
    <div class="sexy-color">
    {% block content %}

    {% endblock %}
    </div>
  </body>
</html>

Now here is the other template:
query.html
{% extends "base.html" %}
{% load static %}

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Query</title>
    <link rel="stylesheet" href="{% static 'main_app/query.css' %}">
  </head>
  <body>
    {% block nav-query %}<strong class="nav-active">Query</strong>{% 
endblock %}
    <div class="cool-padding">
    {% block content %}
    <form method="post" action='/result/'>
      {% csrf_token %}
      {{ form }}
      <input type="submit" value="Submit" />
    </form>
    {% endblock %}
    </div>
  </body>
</html>
Enter code here...

I want query.html to have its own css(query.css):
main.css
.sexy{
  background-color: red;
}

.sexy-color{
  color: yellow;
}



And query.css is:
query.css
.cool-padding{
  padding: 10px,10px,10px,10px;
}
Enter code here...

The problem is i am unable to add 'query.css' to the query.html thus unable 
to use the css code please help.

Regards.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/387e77b9-9340-46e0-bc04-e0fac3175ea3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to