static files not found in django 1.11
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
add a comment |
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
add a comment |
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
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
python django path django-staticfiles static-files
asked Nov 24 '18 at 12:49
Dj.usagiDj.usagi
111
111
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I didn't have,
{% load static %}
and
href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"
adding these solved the problem.
Thank you!
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
add a comment |
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/
I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when runningpython 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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
I didn't have,
{% load static %}
and
href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"
adding these solved the problem.
Thank you!
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
add a comment |
I didn't have,
{% load static %}
and
href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"
adding these solved the problem.
Thank you!
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
add a comment |
I didn't have,
{% load static %}
and
href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"
adding these solved the problem.
Thank you!
I didn't have,
{% load static %}
and
href="{% static 'assets/bootstrap/css/bootstrap.min.css' %}"
adding these solved the problem.
Thank you!
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
add a comment |
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
add a comment |
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/
I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when runningpython 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
add a comment |
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/
I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when runningpython 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
add a comment |
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/
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/
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 runningpython 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
add a comment |
I have tried changing the STATICFILES_DIRS as suggested, but then I become unable to find any static files when runningpython 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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