static files not found in django 1.11












0















I am getting "Not Found" when accessing any page on localhost.
I have read all related posts but still cannot understand why.



I have included 'django.contrib.staticfiles' in INSTALLED_APPS.



I have DEBUG = TRUE in my settings.py



my project layout and code is as the following.



Thank you in advance.



repo_root
├── manage.py

├── project_root
│ │
│ ├── accounts
│ │ ├── migrations
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── models.py
│ │ ├── tests.py
│ │ ├── views.py
│ │ └── urls.py
│ │
│ ├── templates
│ │ └── index.html
│ │
│ └── static
│ └── assets
│ ├── bootstrap
│ ├── css
│ ├── fonts
│ ├── img
│ └── js

├── config_root
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py



settings.py



STATIC_URL = '/static/'

STATICFILES_DIRS = [
os.path.join(
BASE_DIR,
'project_root/static/assets')
]

STATIC_ROOT = os.path.join(
BASE_DIR,
'project_root/staticfiles')


index.html



<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>index</title>
<meta name="description" content="sample_content">
<link rel="stylesheet" href="'static/assets/bootstrap/css/bootstrap.min.css'">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,700,700i,600,600i">
<link rel="stylesheet" href="'static/assets/fonts/simple-line-icons.min.css'">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.css">
<link rel="stylesheet" href="'static/assets/css/smoothproducts.css'">
</head>


urls.py



url(r'^index/$', IndexView.as_view())


views.py



class IndexView(TemplateView):
template_name = "index.html"









share|improve this question



























    0















    I am getting "Not Found" when accessing any page on localhost.
    I have read all related posts but still cannot understand why.



    I have included 'django.contrib.staticfiles' in INSTALLED_APPS.



    I have DEBUG = TRUE in my settings.py



    my project layout and code is as the following.



    Thank you in advance.



    repo_root
    ├── manage.py

    ├── project_root
    │ │
    │ ├── accounts
    │ │ ├── migrations
    │ │ ├── __init__.py
    │ │ ├── admin.py
    │ │ ├── apps.py
    │ │ ├── models.py
    │ │ ├── tests.py
    │ │ ├── views.py
    │ │ └── urls.py
    │ │
    │ ├── templates
    │ │ └── index.html
    │ │
    │ └── static
    │ └── assets
    │ ├── bootstrap
    │ ├── css
    │ ├── fonts
    │ ├── img
    │ └── js

    ├── config_root
    │ ├── __init__.py
    │ ├── settings.py
    │ ├── urls.py
    │ └── wsgi.py



    settings.py



    STATIC_URL = '/static/'

    STATICFILES_DIRS = [
    os.path.join(
    BASE_DIR,
    'project_root/static/assets')
    ]

    STATIC_ROOT = os.path.join(
    BASE_DIR,
    'project_root/staticfiles')


    index.html



    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>index</title>
    <meta name="description" content="sample_content">
    <link rel="stylesheet" href="'static/assets/bootstrap/css/bootstrap.min.css'">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,700,700i,600,600i">
    <link rel="stylesheet" href="'static/assets/fonts/simple-line-icons.min.css'">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.css">
    <link rel="stylesheet" href="'static/assets/css/smoothproducts.css'">
    </head>


    urls.py



    url(r'^index/$', IndexView.as_view())


    views.py



    class IndexView(TemplateView):
    template_name = "index.html"









    share|improve this question

























      0












      0








      0








      I am getting "Not Found" when accessing any page on localhost.
      I have read all related posts but still cannot understand why.



      I have included 'django.contrib.staticfiles' in INSTALLED_APPS.



      I have DEBUG = TRUE in my settings.py



      my project layout and code is as the following.



      Thank you in advance.



      repo_root
      ├── manage.py

      ├── project_root
      │ │
      │ ├── accounts
      │ │ ├── migrations
      │ │ ├── __init__.py
      │ │ ├── admin.py
      │ │ ├── apps.py
      │ │ ├── models.py
      │ │ ├── tests.py
      │ │ ├── views.py
      │ │ └── urls.py
      │ │
      │ ├── templates
      │ │ └── index.html
      │ │
      │ └── static
      │ └── assets
      │ ├── bootstrap
      │ ├── css
      │ ├── fonts
      │ ├── img
      │ └── js

      ├── config_root
      │ ├── __init__.py
      │ ├── settings.py
      │ ├── urls.py
      │ └── wsgi.py



      settings.py



      STATIC_URL = '/static/'

      STATICFILES_DIRS = [
      os.path.join(
      BASE_DIR,
      'project_root/static/assets')
      ]

      STATIC_ROOT = os.path.join(
      BASE_DIR,
      'project_root/staticfiles')


      index.html



      <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
      <title>index</title>
      <meta name="description" content="sample_content">
      <link rel="stylesheet" href="'static/assets/bootstrap/css/bootstrap.min.css'">
      <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,700,700i,600,600i">
      <link rel="stylesheet" href="'static/assets/fonts/simple-line-icons.min.css'">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.css">
      <link rel="stylesheet" href="'static/assets/css/smoothproducts.css'">
      </head>


      urls.py



      url(r'^index/$', IndexView.as_view())


      views.py



      class IndexView(TemplateView):
      template_name = "index.html"









      share|improve this question














      I am getting "Not Found" when accessing any page on localhost.
      I have read all related posts but still cannot understand why.



      I have included 'django.contrib.staticfiles' in INSTALLED_APPS.



      I have DEBUG = TRUE in my settings.py



      my project layout and code is as the following.



      Thank you in advance.



      repo_root
      ├── manage.py

      ├── project_root
      │ │
      │ ├── accounts
      │ │ ├── migrations
      │ │ ├── __init__.py
      │ │ ├── admin.py
      │ │ ├── apps.py
      │ │ ├── models.py
      │ │ ├── tests.py
      │ │ ├── views.py
      │ │ └── urls.py
      │ │
      │ ├── templates
      │ │ └── index.html
      │ │
      │ └── static
      │ └── assets
      │ ├── bootstrap
      │ ├── css
      │ ├── fonts
      │ ├── img
      │ └── js

      ├── config_root
      │ ├── __init__.py
      │ ├── settings.py
      │ ├── urls.py
      │ └── wsgi.py



      settings.py



      STATIC_URL = '/static/'

      STATICFILES_DIRS = [
      os.path.join(
      BASE_DIR,
      'project_root/static/assets')
      ]

      STATIC_ROOT = os.path.join(
      BASE_DIR,
      'project_root/staticfiles')


      index.html



      <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
      <title>index</title>
      <meta name="description" content="sample_content">
      <link rel="stylesheet" href="'static/assets/bootstrap/css/bootstrap.min.css'">
      <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,400i,700,700i,600,600i">
      <link rel="stylesheet" href="'static/assets/fonts/simple-line-icons.min.css'">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.css">
      <link rel="stylesheet" href="'static/assets/css/smoothproducts.css'">
      </head>


      urls.py



      url(r'^index/$', IndexView.as_view())


      views.py



      class IndexView(TemplateView):
      template_name = "index.html"






      python django path django-staticfiles static-files






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 12:49









      Dj.usagiDj.usagi

      111




      111
























          2 Answers
          2






          active

          oldest

          votes


















          1














          I didn't have,



          {% load static %}



          and



          href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"



          adding these solved the problem.



          Thank you!






          share|improve this answer
























          • Great that you solved it. Accepting an answer or upvote it would be nice, if it helped.

            – Uroš Trstenjak
            Nov 24 '18 at 14:56



















          0














          Your STATICFILES_DIRS isn't defined properly. Your BASE_DIR is most probably defined as your project_root folder, since this is the default Django setting. You should leave out project_root in your definition.



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



          You should also include static files urls to your urlpatterns.



          Check Django docs for further info https://docs.djangoproject.com/en/2.1/howto/static-files/






          share|improve this answer


























          • I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when running python manage.py findstatic.

            – Dj.usagi
            Nov 24 '18 at 13:15











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

            – Dj.usagi
            Nov 24 '18 at 13:16











          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%2f53458321%2fstatic-files-not-found-in-django-1-11%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









          1














          I didn't have,



          {% load static %}



          and



          href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"



          adding these solved the problem.



          Thank you!






          share|improve this answer
























          • Great that you solved it. Accepting an answer or upvote it would be nice, if it helped.

            – Uroš Trstenjak
            Nov 24 '18 at 14:56
















          1














          I didn't have,



          {% load static %}



          and



          href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"



          adding these solved the problem.



          Thank you!






          share|improve this answer
























          • Great that you solved it. Accepting an answer or upvote it would be nice, if it helped.

            – Uroš Trstenjak
            Nov 24 '18 at 14:56














          1












          1








          1







          I didn't have,



          {% load static %}



          and



          href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"



          adding these solved the problem.



          Thank you!






          share|improve this answer













          I didn't have,



          {% load static %}



          and



          href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"



          adding these solved the problem.



          Thank you!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 13:48









          Dj.usagiDj.usagi

          111




          111













          • Great that you solved it. Accepting an answer or upvote it would be nice, if it helped.

            – Uroš Trstenjak
            Nov 24 '18 at 14:56



















          • Great that you solved it. Accepting an answer or upvote it would be nice, if it helped.

            – Uroš Trstenjak
            Nov 24 '18 at 14:56

















          Great that you solved it. Accepting an answer or upvote it would be nice, if it helped.

          – Uroš Trstenjak
          Nov 24 '18 at 14:56





          Great that you solved it. Accepting an answer or upvote it would be nice, if it helped.

          – Uroš Trstenjak
          Nov 24 '18 at 14:56













          0














          Your STATICFILES_DIRS isn't defined properly. Your BASE_DIR is most probably defined as your project_root folder, since this is the default Django setting. You should leave out project_root in your definition.



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



          You should also include static files urls to your urlpatterns.



          Check Django docs for further info https://docs.djangoproject.com/en/2.1/howto/static-files/






          share|improve this answer


























          • I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when running python manage.py findstatic.

            – Dj.usagi
            Nov 24 '18 at 13:15











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

            – Dj.usagi
            Nov 24 '18 at 13:16
















          0














          Your STATICFILES_DIRS isn't defined properly. Your BASE_DIR is most probably defined as your project_root folder, since this is the default Django setting. You should leave out project_root in your definition.



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



          You should also include static files urls to your urlpatterns.



          Check Django docs for further info https://docs.djangoproject.com/en/2.1/howto/static-files/






          share|improve this answer


























          • I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when running python manage.py findstatic.

            – Dj.usagi
            Nov 24 '18 at 13:15











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

            – Dj.usagi
            Nov 24 '18 at 13:16














          0












          0








          0







          Your STATICFILES_DIRS isn't defined properly. Your BASE_DIR is most probably defined as your project_root folder, since this is the default Django setting. You should leave out project_root in your definition.



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



          You should also include static files urls to your urlpatterns.



          Check Django docs for further info https://docs.djangoproject.com/en/2.1/howto/static-files/






          share|improve this answer















          Your STATICFILES_DIRS isn't defined properly. Your BASE_DIR is most probably defined as your project_root folder, since this is the default Django setting. You should leave out project_root in your definition.



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



          You should also include static files urls to your urlpatterns.



          Check Django docs for further info https://docs.djangoproject.com/en/2.1/howto/static-files/







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 24 '18 at 13:03

























          answered Nov 24 '18 at 12:56









          Uroš TrstenjakUroš Trstenjak

          578413




          578413













          • I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when running python manage.py findstatic.

            – Dj.usagi
            Nov 24 '18 at 13:15











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

            – Dj.usagi
            Nov 24 '18 at 13:16



















          • I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when running python manage.py findstatic.

            – Dj.usagi
            Nov 24 '18 at 13:15











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

            – Dj.usagi
            Nov 24 '18 at 13:16

















          I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when running python manage.py findstatic.

          – Dj.usagi
          Nov 24 '18 at 13:15





          I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when running python manage.py findstatic.

          – Dj.usagi
          Nov 24 '18 at 13:15













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

          – Dj.usagi
          Nov 24 '18 at 13:16





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

          – Dj.usagi
          Nov 24 '18 at 13:16


















          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%2f53458321%2fstatic-files-not-found-in-django-1-11%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

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks