Django static files not loading even with STATICFILES_DIR set to correct path












0















I've looked at so many similar questions on Stack overflow and other websites but I cant seem to figure out why my static files aren't loading.



I have created my base template based on a tutorial online, and it should work like magic. But my static files arent rendering with the view. When I go to the developer console on chrome I see that the css and js files are not found. the exact error is:



> 127.0.0.1/:8 GET http://127.0.0.1:8000/static/css/bootstrap.min.css net::ERR_ABORTED 404 (Not Found)
> 127.0.0.1/:117 GET http://127.0.0.1:8000/static/js/jquery-3.3.1.min.js net::ERR_ABORTED 404 (Not Found)
> 127.0.0.1/:118 GET http://127.0.0.1:8000/static/js/popper.min.js net::ERR_ABORTED 404 (Not Found)
> 127.0.0.1/:119 GET http://127.0.0.1:8000/static/js/bootstrap.min.js net::ERR_ABORTED 404 (Not Found)


Here is my base template:






{% load static from staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %}Django Forms{% endblock %}</title>

<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
{% block stylesheets %}
{% endblock stylesheets %}

</head>
<body>
{% block body %}
<nav class="navbar navbar-expand-sm navbar-dark bg-dark" >
<div class="container" >
<a class="navbar-brand" href="{% url 'home' %}">Blog App</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainMenu" aria-controls="mainMenu" aria-expanded="false" aria-label="Toggle navigation" >
<span class="navbar-toggler-icon" ></span>
</button>
<div class="collapse navbar-collapse" id="mainMenu" >
<ul class="navbar-nav ml-auto" >

<li class="nav-item dropdown" >
<a class="nav-link dropdown-toggle" href="#" id="userMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{user.username}}
</a>
<div class="dropdown-menu dropdown-menu-right"aria-labelledby="userMenu">
<a class="dropdown-item" href="#">My account</a>
<a class="dropdown-item" href="#" >Change password</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url 'logout' %}">Log out</a>
</div>
</li>
</ul>

</div>
</div>
</nav>

<div class="container" >
<ol class = "breadcrumb my-4">
{% block breadcrumb %}
{% endblock %}
</ol>

{% block content %}
{% endblock %}
</div>

{% endblock body %}

<script type="text/javascript" src="{% static 'js/jquery-3.3.1.min.js' %}" ></script>
<script type="text/javascript" src="{% static 'js/popper.min.js' %}" ></script>
<script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}" ></script>
</body>
</html>





Here is my Settings.py



BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'widget_tweaks',

'accounts',
'blog',


]
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')

STATICFILES_DIR = (
os.path.join(BASE_DIR, 'static'),
# os.path.join(BASE_DIR,'myformapp', 'static','js')
)

STATIC_URL = '/static/'

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)


My folder structure:



Formproject
|___________myformapp
|___________accounts
|___________blog
|___________myformapp
|__________templates
|__________includes
|__________base.html
|__________other_templates.html
|_____________init__.py
|___________settings.py
|___________urls.py
____________static
____________static_root









share|improve this question





























    0















    I've looked at so many similar questions on Stack overflow and other websites but I cant seem to figure out why my static files aren't loading.



    I have created my base template based on a tutorial online, and it should work like magic. But my static files arent rendering with the view. When I go to the developer console on chrome I see that the css and js files are not found. the exact error is:



    > 127.0.0.1/:8 GET http://127.0.0.1:8000/static/css/bootstrap.min.css net::ERR_ABORTED 404 (Not Found)
    > 127.0.0.1/:117 GET http://127.0.0.1:8000/static/js/jquery-3.3.1.min.js net::ERR_ABORTED 404 (Not Found)
    > 127.0.0.1/:118 GET http://127.0.0.1:8000/static/js/popper.min.js net::ERR_ABORTED 404 (Not Found)
    > 127.0.0.1/:119 GET http://127.0.0.1:8000/static/js/bootstrap.min.js net::ERR_ABORTED 404 (Not Found)


    Here is my base template:






    {% load static from staticfiles %}
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>{% block title %}Django Forms{% endblock %}</title>

    <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
    {% block stylesheets %}
    {% endblock stylesheets %}

    </head>
    <body>
    {% block body %}
    <nav class="navbar navbar-expand-sm navbar-dark bg-dark" >
    <div class="container" >
    <a class="navbar-brand" href="{% url 'home' %}">Blog App</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainMenu" aria-controls="mainMenu" aria-expanded="false" aria-label="Toggle navigation" >
    <span class="navbar-toggler-icon" ></span>
    </button>
    <div class="collapse navbar-collapse" id="mainMenu" >
    <ul class="navbar-nav ml-auto" >

    <li class="nav-item dropdown" >
    <a class="nav-link dropdown-toggle" href="#" id="userMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    {{user.username}}
    </a>
    <div class="dropdown-menu dropdown-menu-right"aria-labelledby="userMenu">
    <a class="dropdown-item" href="#">My account</a>
    <a class="dropdown-item" href="#" >Change password</a>
    <div class="dropdown-divider"></div>
    <a class="dropdown-item" href="{% url 'logout' %}">Log out</a>
    </div>
    </li>
    </ul>

    </div>
    </div>
    </nav>

    <div class="container" >
    <ol class = "breadcrumb my-4">
    {% block breadcrumb %}
    {% endblock %}
    </ol>

    {% block content %}
    {% endblock %}
    </div>

    {% endblock body %}

    <script type="text/javascript" src="{% static 'js/jquery-3.3.1.min.js' %}" ></script>
    <script type="text/javascript" src="{% static 'js/popper.min.js' %}" ></script>
    <script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}" ></script>
    </body>
    </html>





    Here is my Settings.py



    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

    INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'widget_tweaks',

    'accounts',
    'blog',


    ]
    STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')

    STATICFILES_DIR = (
    os.path.join(BASE_DIR, 'static'),
    # os.path.join(BASE_DIR,'myformapp', 'static','js')
    )

    STATIC_URL = '/static/'

    STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    )


    My folder structure:



    Formproject
    |___________myformapp
    |___________accounts
    |___________blog
    |___________myformapp
    |__________templates
    |__________includes
    |__________base.html
    |__________other_templates.html
    |_____________init__.py
    |___________settings.py
    |___________urls.py
    ____________static
    ____________static_root









    share|improve this question



























      0












      0








      0








      I've looked at so many similar questions on Stack overflow and other websites but I cant seem to figure out why my static files aren't loading.



      I have created my base template based on a tutorial online, and it should work like magic. But my static files arent rendering with the view. When I go to the developer console on chrome I see that the css and js files are not found. the exact error is:



      > 127.0.0.1/:8 GET http://127.0.0.1:8000/static/css/bootstrap.min.css net::ERR_ABORTED 404 (Not Found)
      > 127.0.0.1/:117 GET http://127.0.0.1:8000/static/js/jquery-3.3.1.min.js net::ERR_ABORTED 404 (Not Found)
      > 127.0.0.1/:118 GET http://127.0.0.1:8000/static/js/popper.min.js net::ERR_ABORTED 404 (Not Found)
      > 127.0.0.1/:119 GET http://127.0.0.1:8000/static/js/bootstrap.min.js net::ERR_ABORTED 404 (Not Found)


      Here is my base template:






      {% load static from staticfiles %}
      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="UTF-8">
      <title>{% block title %}Django Forms{% endblock %}</title>

      <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
      {% block stylesheets %}
      {% endblock stylesheets %}

      </head>
      <body>
      {% block body %}
      <nav class="navbar navbar-expand-sm navbar-dark bg-dark" >
      <div class="container" >
      <a class="navbar-brand" href="{% url 'home' %}">Blog App</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainMenu" aria-controls="mainMenu" aria-expanded="false" aria-label="Toggle navigation" >
      <span class="navbar-toggler-icon" ></span>
      </button>
      <div class="collapse navbar-collapse" id="mainMenu" >
      <ul class="navbar-nav ml-auto" >

      <li class="nav-item dropdown" >
      <a class="nav-link dropdown-toggle" href="#" id="userMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      {{user.username}}
      </a>
      <div class="dropdown-menu dropdown-menu-right"aria-labelledby="userMenu">
      <a class="dropdown-item" href="#">My account</a>
      <a class="dropdown-item" href="#" >Change password</a>
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" href="{% url 'logout' %}">Log out</a>
      </div>
      </li>
      </ul>

      </div>
      </div>
      </nav>

      <div class="container" >
      <ol class = "breadcrumb my-4">
      {% block breadcrumb %}
      {% endblock %}
      </ol>

      {% block content %}
      {% endblock %}
      </div>

      {% endblock body %}

      <script type="text/javascript" src="{% static 'js/jquery-3.3.1.min.js' %}" ></script>
      <script type="text/javascript" src="{% static 'js/popper.min.js' %}" ></script>
      <script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}" ></script>
      </body>
      </html>





      Here is my Settings.py



      BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

      INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',

      'widget_tweaks',

      'accounts',
      'blog',


      ]
      STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')

      STATICFILES_DIR = (
      os.path.join(BASE_DIR, 'static'),
      # os.path.join(BASE_DIR,'myformapp', 'static','js')
      )

      STATIC_URL = '/static/'

      STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.FileSystemFinder',
      'django.contrib.staticfiles.finders.AppDirectoriesFinder',
      )


      My folder structure:



      Formproject
      |___________myformapp
      |___________accounts
      |___________blog
      |___________myformapp
      |__________templates
      |__________includes
      |__________base.html
      |__________other_templates.html
      |_____________init__.py
      |___________settings.py
      |___________urls.py
      ____________static
      ____________static_root









      share|improve this question
















      I've looked at so many similar questions on Stack overflow and other websites but I cant seem to figure out why my static files aren't loading.



      I have created my base template based on a tutorial online, and it should work like magic. But my static files arent rendering with the view. When I go to the developer console on chrome I see that the css and js files are not found. the exact error is:



      > 127.0.0.1/:8 GET http://127.0.0.1:8000/static/css/bootstrap.min.css net::ERR_ABORTED 404 (Not Found)
      > 127.0.0.1/:117 GET http://127.0.0.1:8000/static/js/jquery-3.3.1.min.js net::ERR_ABORTED 404 (Not Found)
      > 127.0.0.1/:118 GET http://127.0.0.1:8000/static/js/popper.min.js net::ERR_ABORTED 404 (Not Found)
      > 127.0.0.1/:119 GET http://127.0.0.1:8000/static/js/bootstrap.min.js net::ERR_ABORTED 404 (Not Found)


      Here is my base template:






      {% load static from staticfiles %}
      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="UTF-8">
      <title>{% block title %}Django Forms{% endblock %}</title>

      <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
      {% block stylesheets %}
      {% endblock stylesheets %}

      </head>
      <body>
      {% block body %}
      <nav class="navbar navbar-expand-sm navbar-dark bg-dark" >
      <div class="container" >
      <a class="navbar-brand" href="{% url 'home' %}">Blog App</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainMenu" aria-controls="mainMenu" aria-expanded="false" aria-label="Toggle navigation" >
      <span class="navbar-toggler-icon" ></span>
      </button>
      <div class="collapse navbar-collapse" id="mainMenu" >
      <ul class="navbar-nav ml-auto" >

      <li class="nav-item dropdown" >
      <a class="nav-link dropdown-toggle" href="#" id="userMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      {{user.username}}
      </a>
      <div class="dropdown-menu dropdown-menu-right"aria-labelledby="userMenu">
      <a class="dropdown-item" href="#">My account</a>
      <a class="dropdown-item" href="#" >Change password</a>
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" href="{% url 'logout' %}">Log out</a>
      </div>
      </li>
      </ul>

      </div>
      </div>
      </nav>

      <div class="container" >
      <ol class = "breadcrumb my-4">
      {% block breadcrumb %}
      {% endblock %}
      </ol>

      {% block content %}
      {% endblock %}
      </div>

      {% endblock body %}

      <script type="text/javascript" src="{% static 'js/jquery-3.3.1.min.js' %}" ></script>
      <script type="text/javascript" src="{% static 'js/popper.min.js' %}" ></script>
      <script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}" ></script>
      </body>
      </html>





      Here is my Settings.py



      BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

      INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',

      'widget_tweaks',

      'accounts',
      'blog',


      ]
      STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')

      STATICFILES_DIR = (
      os.path.join(BASE_DIR, 'static'),
      # os.path.join(BASE_DIR,'myformapp', 'static','js')
      )

      STATIC_URL = '/static/'

      STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.FileSystemFinder',
      'django.contrib.staticfiles.finders.AppDirectoriesFinder',
      )


      My folder structure:



      Formproject
      |___________myformapp
      |___________accounts
      |___________blog
      |___________myformapp
      |__________templates
      |__________includes
      |__________base.html
      |__________other_templates.html
      |_____________init__.py
      |___________settings.py
      |___________urls.py
      ____________static
      ____________static_root





      {% load static from staticfiles %}
      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="UTF-8">
      <title>{% block title %}Django Forms{% endblock %}</title>

      <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
      {% block stylesheets %}
      {% endblock stylesheets %}

      </head>
      <body>
      {% block body %}
      <nav class="navbar navbar-expand-sm navbar-dark bg-dark" >
      <div class="container" >
      <a class="navbar-brand" href="{% url 'home' %}">Blog App</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainMenu" aria-controls="mainMenu" aria-expanded="false" aria-label="Toggle navigation" >
      <span class="navbar-toggler-icon" ></span>
      </button>
      <div class="collapse navbar-collapse" id="mainMenu" >
      <ul class="navbar-nav ml-auto" >

      <li class="nav-item dropdown" >
      <a class="nav-link dropdown-toggle" href="#" id="userMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      {{user.username}}
      </a>
      <div class="dropdown-menu dropdown-menu-right"aria-labelledby="userMenu">
      <a class="dropdown-item" href="#">My account</a>
      <a class="dropdown-item" href="#" >Change password</a>
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" href="{% url 'logout' %}">Log out</a>
      </div>
      </li>
      </ul>

      </div>
      </div>
      </nav>

      <div class="container" >
      <ol class = "breadcrumb my-4">
      {% block breadcrumb %}
      {% endblock %}
      </ol>

      {% block content %}
      {% endblock %}
      </div>

      {% endblock body %}

      <script type="text/javascript" src="{% static 'js/jquery-3.3.1.min.js' %}" ></script>
      <script type="text/javascript" src="{% static 'js/popper.min.js' %}" ></script>
      <script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}" ></script>
      </body>
      </html>





      {% load static from staticfiles %}
      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="UTF-8">
      <title>{% block title %}Django Forms{% endblock %}</title>

      <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
      {% block stylesheets %}
      {% endblock stylesheets %}

      </head>
      <body>
      {% block body %}
      <nav class="navbar navbar-expand-sm navbar-dark bg-dark" >
      <div class="container" >
      <a class="navbar-brand" href="{% url 'home' %}">Blog App</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mainMenu" aria-controls="mainMenu" aria-expanded="false" aria-label="Toggle navigation" >
      <span class="navbar-toggler-icon" ></span>
      </button>
      <div class="collapse navbar-collapse" id="mainMenu" >
      <ul class="navbar-nav ml-auto" >

      <li class="nav-item dropdown" >
      <a class="nav-link dropdown-toggle" href="#" id="userMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      {{user.username}}
      </a>
      <div class="dropdown-menu dropdown-menu-right"aria-labelledby="userMenu">
      <a class="dropdown-item" href="#">My account</a>
      <a class="dropdown-item" href="#" >Change password</a>
      <div class="dropdown-divider"></div>
      <a class="dropdown-item" href="{% url 'logout' %}">Log out</a>
      </div>
      </li>
      </ul>

      </div>
      </div>
      </nav>

      <div class="container" >
      <ol class = "breadcrumb my-4">
      {% block breadcrumb %}
      {% endblock %}
      </ol>

      {% block content %}
      {% endblock %}
      </div>

      {% endblock body %}

      <script type="text/javascript" src="{% static 'js/jquery-3.3.1.min.js' %}" ></script>
      <script type="text/javascript" src="{% static 'js/popper.min.js' %}" ></script>
      <script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}" ></script>
      </body>
      </html>






      javascript python css django






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 19 at 6:25







      Sam DiceOnFire

















      asked Jan 19 at 6:18









      Sam DiceOnFireSam DiceOnFire

      44




      44
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Your templates and static folders are not under the same root, it might be the problem. Anyway, try adding this to the project's settings.py:



          STATICFILES_DIRS = (
          os.path.join(BASE_DIR, 'static'),
          )


          Then, use your CSS files in HTML:



          {% load static %}
          <link rel="stylesheet" type="text/css" href="{% static 'css/style.css'%}">


          This should work fine.






          share|improve this answer


























          • I've added {%load static%} on the top of the template file.. Are u asking me to put it right before the <link> tag?

            – Sam DiceOnFire
            Jan 19 at 10:15











          • I changed the path for the static and templates folder. added the templates and static folders under the same root. didn't work

            – Sam DiceOnFire
            Jan 19 at 13:06



















          0














          I found that it was a basic mistake on my part.



          on my template i had done up my <link> tag as follows



          <link rel = "stylesheets" src="file source here">


          while it should have been



          <link rel = "stylesheets" href="file source here">


          such a newbie mistake.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264600%2fdjango-static-files-not-loading-even-with-staticfiles-dir-set-to-correct-path%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Your templates and static folders are not under the same root, it might be the problem. Anyway, try adding this to the project's settings.py:



            STATICFILES_DIRS = (
            os.path.join(BASE_DIR, 'static'),
            )


            Then, use your CSS files in HTML:



            {% load static %}
            <link rel="stylesheet" type="text/css" href="{% static 'css/style.css'%}">


            This should work fine.






            share|improve this answer


























            • I've added {%load static%} on the top of the template file.. Are u asking me to put it right before the <link> tag?

              – Sam DiceOnFire
              Jan 19 at 10:15











            • I changed the path for the static and templates folder. added the templates and static folders under the same root. didn't work

              – Sam DiceOnFire
              Jan 19 at 13:06
















            0














            Your templates and static folders are not under the same root, it might be the problem. Anyway, try adding this to the project's settings.py:



            STATICFILES_DIRS = (
            os.path.join(BASE_DIR, 'static'),
            )


            Then, use your CSS files in HTML:



            {% load static %}
            <link rel="stylesheet" type="text/css" href="{% static 'css/style.css'%}">


            This should work fine.






            share|improve this answer


























            • I've added {%load static%} on the top of the template file.. Are u asking me to put it right before the <link> tag?

              – Sam DiceOnFire
              Jan 19 at 10:15











            • I changed the path for the static and templates folder. added the templates and static folders under the same root. didn't work

              – Sam DiceOnFire
              Jan 19 at 13:06














            0












            0








            0







            Your templates and static folders are not under the same root, it might be the problem. Anyway, try adding this to the project's settings.py:



            STATICFILES_DIRS = (
            os.path.join(BASE_DIR, 'static'),
            )


            Then, use your CSS files in HTML:



            {% load static %}
            <link rel="stylesheet" type="text/css" href="{% static 'css/style.css'%}">


            This should work fine.






            share|improve this answer















            Your templates and static folders are not under the same root, it might be the problem. Anyway, try adding this to the project's settings.py:



            STATICFILES_DIRS = (
            os.path.join(BASE_DIR, 'static'),
            )


            Then, use your CSS files in HTML:



            {% load static %}
            <link rel="stylesheet" type="text/css" href="{% static 'css/style.css'%}">


            This should work fine.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 20 at 15:33

























            answered Jan 19 at 7:09









            M Yasin YM Yasin Y

            666




            666













            • I've added {%load static%} on the top of the template file.. Are u asking me to put it right before the <link> tag?

              – Sam DiceOnFire
              Jan 19 at 10:15











            • I changed the path for the static and templates folder. added the templates and static folders under the same root. didn't work

              – Sam DiceOnFire
              Jan 19 at 13:06



















            • I've added {%load static%} on the top of the template file.. Are u asking me to put it right before the <link> tag?

              – Sam DiceOnFire
              Jan 19 at 10:15











            • I changed the path for the static and templates folder. added the templates and static folders under the same root. didn't work

              – Sam DiceOnFire
              Jan 19 at 13:06

















            I've added {%load static%} on the top of the template file.. Are u asking me to put it right before the <link> tag?

            – Sam DiceOnFire
            Jan 19 at 10:15





            I've added {%load static%} on the top of the template file.. Are u asking me to put it right before the <link> tag?

            – Sam DiceOnFire
            Jan 19 at 10:15













            I changed the path for the static and templates folder. added the templates and static folders under the same root. didn't work

            – Sam DiceOnFire
            Jan 19 at 13:06





            I changed the path for the static and templates folder. added the templates and static folders under the same root. didn't work

            – Sam DiceOnFire
            Jan 19 at 13:06













            0














            I found that it was a basic mistake on my part.



            on my template i had done up my <link> tag as follows



            <link rel = "stylesheets" src="file source here">


            while it should have been



            <link rel = "stylesheets" href="file source here">


            such a newbie mistake.






            share|improve this answer




























              0














              I found that it was a basic mistake on my part.



              on my template i had done up my <link> tag as follows



              <link rel = "stylesheets" src="file source here">


              while it should have been



              <link rel = "stylesheets" href="file source here">


              such a newbie mistake.






              share|improve this answer


























                0












                0








                0







                I found that it was a basic mistake on my part.



                on my template i had done up my <link> tag as follows



                <link rel = "stylesheets" src="file source here">


                while it should have been



                <link rel = "stylesheets" href="file source here">


                such a newbie mistake.






                share|improve this answer













                I found that it was a basic mistake on my part.



                on my template i had done up my <link> tag as follows



                <link rel = "stylesheets" src="file source here">


                while it should have been



                <link rel = "stylesheets" href="file source here">


                such a newbie mistake.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 26 at 2:17









                Sam DiceOnFireSam DiceOnFire

                44




                44






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264600%2fdjango-static-files-not-loading-even-with-staticfiles-dir-set-to-correct-path%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Liquibase includeAll doesn't find base path

                    How to use setInterval in EJS file?

                    Petrus Granier-Deferre