title: Load css file with Jinja2 in Django
body: <p>I am using Jinja2 version 2.10 with Django. I get a not found error for my css stylesheet. I have read every question on Stackoverflow related to Jinja2 templating in Django and tried all the answers, still no success. </p>
  
  <p>My jinja2 config file (top level in my Django project): </p>
  
  <pre><code>from django.contrib.staticfiles.storage import staticfiles_storage
  from django.urls import reverse
  from jinja2 import Environment
  
  # This enables us to use Django template tags like {% url ‘index’ %} or {% static ‘path/to/static/file.js’ %} in our Jinja2 templates. 
  def environment(**options):
      env = Environment(**options)
      env.globals.update({
          'static': staticfiles_storage.url,
          'url': reverse,
      })
      return env
  </code></pre>
  
  <p>My html templates load as expected and the page shows in the browser, it's just the css load that isn't working. My folder structure is:</p>
  
  <p>Django_project </p>
  
  <pre><code>-- my_app folder
        -- Jinja2
        |      -- my_app
        |          -- .html files
        | -- static
                -- my_app
                    -- styles
                        -- .css file
  </code></pre>
  
  <p>That is, jinja2 and static are both folders on the same level inside my_app folder. </p>
  
  <p>My base.html file:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html lang="en"&gt;
   &lt;head&gt;
     &lt;meta charset="utf-8"&gt;
      &lt;!--bootstrap responsive viewport: mobile device optimization first --&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt;
      &lt;bootstrapp css goes here&gt;
  
      &lt;link rel="stylesheet" type="text/css" href="/my_app/static/styles/my_app.css"&gt;
  
      &lt;!-- defines an area that child templates fill --&gt;
      {% block head %}
  
      {% endblock head %}
   &lt;/head&gt;
  </code></pre>
  
  <p>I tried using the {% static 'path/goes/here.css' %} and got an error message on 'static' unrecognized. But if I use the normal {% load static %} Django tags at the top of the file, I get an error that 'load' is an unrecognized tag (which I expected because I'm using Jinja2). </p>
  
  <p>Bootstrap css loads. I've tried excluding the bootstrap links, that makes no difference. 
  I've tried using a static prefix in Jinja2 environment globals, as explained <a href="https://stackoverflow.com/questions/42064874/jinja2-link-to-static-files">here</a>, it seems to make no difference. </p>
  
  <p>I've read the Jinja2 and Django documentation and followed all the set up recommendations. css templates load in other Django projects where I'm not using Jinja2, using {% load static %}.</p>
  
  <p>Is hardcoding the href the right thing to do? I've tried every possible combination of path reference in case I was just putting the wrong path there. The error message is 'not found: path/etc/etc.css' </p>
  
  <p>Any help much appreciated, thanks!  </p>