2

I have a html template that is rendered through index view. It has a couple static css that are referenced:

  <html lang="pt-pt">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>AppGestao by Araujo</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
      <meta name="viewport" content="width=device-width" />

     <!--STYLE FILES START-->
      {% load staticfiles %}
      <!-- Bootstrap core CSS     -->
      <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" type="text/css"/>
      <!-- Animation library for notifications   -->
      <link href="{% static 'css/animate.min.css' %}" rel="stylesheet"  type="text/css"/>
      <!--  Light Bootstrap Table core CSS    -->
      <link href="{% static 'css/light-bootstrap-dashboard.css?v=1.4.0' %}" rel="stylesheet"  type="text/css"/>
      <!--STYLE FILES END-->
  </head>

I have the files inside APP_NAME/static/css If I run this html alone without django rendering and manuel reference to static css works perfect. If I do it through {%static it don't.

Despite this, when I see source code in chrome, they look exactly the same with same css links!

hopieman
  • 399
  • 7
  • 22

2 Answers2

1

I solved this problem by changing this

 <link href="{% static 'css/light-bootstrap-dashboard.css?v=1.4.0' %}" rel="stylesheet"  type="text/css"/>

to

 <link href="{% static 'css/light-bootstrap-dashboard.css' %}" rel="stylesheet"  type="text/css"/>

It's strange because it works without django. Why is that version there? (this was taken by an official bootstrap template)

hopieman
  • 399
  • 7
  • 22
0

It looks like what you need is static urls that also get passed GET parameters like is shown in this post previous SO post

Simply add them to the end:

<a href="{% static css/css.css %}?office=foobar">

For Django 1.5+

<a href="{% static 'css/css.css' %}?office=foobar">
sahutchi
  • 2,223
  • 2
  • 19
  • 20