引导文件404 Django [英] Bootstrap files 404 Django
问题描述
在FireBug上,我收到了这些错误:
GET http:// localhost:8000 / static / bootstrap / css / bootstrap。 min.css 404(NOT FOUND)localhost /:7
GET http:// localhost:8000 / static / bootstrap / js / bootstrap.min.js 404(NOT FOUND)localhost /:8
GET http:// localhost:8000 / static / bootstrap / css / bootstrap.min.css 404(NOT FOUND)
我的STATIC_ROOT是:
$ $ p $ STATIC_ROOT ='/ home / bradford / Development / Django / public_pictures / static'
我将自举文件放在静态目录中。这个'静态'目录位于我的项目'public_pictures'中。我不确定这些文件为何无法找到
这是我的HTML档案:
<!DOCTYPE html>
{%load staticfiles%}
< head>
< link rel =stylesheethref ={%staticbootstrap / css / bootstrap.min.css%}type =text / cssmedia =screen/> ;
< script type =text / javascriptsrc ={%staticbootstrap / js / bootstrap.min.js%}>< / script>
< / head>
< html>
< body>
< span class =徽章徽章成功> HI!< / span>
< span class =badge> 1< / span>
< span class =badge badge-warning> 4< / span>
< span class =徽章徽章 - 重要> 6< / span>
< span class =badge badge-info> 8< / span>
< span class =badge badge-inverse> 10< / span>
< / body>
< / html>
因此,这些引导徽章仅显示常规文本。
任何输入值得赞赏谢谢!!
** * ** * 强> 修改的 * ** * ** * ** * ***
现在,我的STATICFILES_DIRS在settings.py中是
STATICFILES_DIR =('/ home / bradford / Development / Django / public_pictures / static',)
STATIC_ROOT ='',#blank
STATIC_URL ='/ static /'
DEBUG = True
urls.py:
来自django.conf .urls import include,url,patterns
$ b $ urlpatterns = patterns('',
url(r'homepage /',include('homepage.urls',namespace =homepage)) ,
)
index.html(模板)
<!DOCTYPE html>
{%load staticfiles%}
< head>
< link rel =stylesheethref ={%staticbootstrap / css / bootstrap.min.css%}type =text / cssmedia =screen/> ;
< script type =text / javascriptsrc ={%staticbootstrap / js / bootstrap.min.js%}>< / script>
< / head>
< html>
< body>
< span class =徽章徽章成功> HI!< / span>
< span class =badge> 1< / span>
< span class =badge badge-warning> 4< / span>
< span class =徽章徽章 - 重要> 6< / span>
< span class =badge badge-info> 8< / span>
< span class =badge badge-inverse> 10< / span>
< / body>
< / html>
所有这些变化都让我更接近我的目标。但是显示引导程序的徽章,但没有显示颜色。一切都是灰色的白色文字= [我不确定其他功能是否也适用。我会尝试他们。再次感谢您的帮助!非常感谢!
开发服务器:
将 STATIC_ROOT
清空。
对 STATICFILES_DIRS 进行更改
STATICFILES_DIRS =(
'/ home / bradford / Development / Django / public_pictures / static',
)
运行 ./ manage.py collectstatic
应该有效。
On FireBug I get these errors
GET http://localhost:8000/static/bootstrap/css/bootstrap.min.css 404 (NOT FOUND) localhost/:7
GET http://localhost:8000/static/bootstrap/js/bootstrap.min.js 404 (NOT FOUND) localhost/:8
GET http://localhost:8000/static/bootstrap/css/bootstrap.min.css 404 (NOT FOUND)
My STATIC_ROOT is :
STATIC_ROOT = '/home/bradford/Development/Django/public_pictures/static'
I placed my bootstrap files in a 'static' directory. This 'static' directory is located in my project named 'public_pictures'. I'm not sure why these files can't be located
Here is my HTML file:
<!DOCTYPE html>
{% load staticfiles %}
<head>
<link rel="stylesheet" href="{% static "bootstrap/css/bootstrap.min.css" %}" type="text/css" media="screen" />
<script type="text/javascript" src="{% static "bootstrap/js/bootstrap.min.js" %}" ></script>
</head>
<html>
<body>
<span class="badge badge-success" >HI!</span>
<span class="badge">1</span>
<span class="badge badge-warning">4</span>
<span class="badge badge-important">6</span>
<span class="badge badge-info">8</span>
<span class="badge badge-inverse">10</span>
</body>
</html>
As a result, only regular text is displayed for these bootstrap badges.
Any input is appreciated thank you!!
******EDIT*************
So as of right now my STATICFILES_DIRS in settings.py is
STATICFILES_DIR = ('/home/bradford/Development/Django/public_pictures/static',)
STATIC_ROOT = '', # blank
STATIC_URL = '/static/'
DEBUG = True
urls.py:
from django.conf.urls import include, url, patterns
urlpatterns = patterns('',
url(r'homepage/',include('homepage.urls', namespace = "homepage")),
)
index.html (template)
<!DOCTYPE html>
{% load staticfiles %}
<head>
<link rel="stylesheet" href="{% static "bootstrap/css/bootstrap.min.css" %}" type="text/css" media="screen" />
<script type="text/javascript" src="{% static "bootstrap/js/bootstrap.min.js" %}" ></script>
</head>
<html>
<body>
<span class="badge badge-success" >HI!</span>
<span class="badge">1</span>
<span class="badge badge-warning">4</span>
<span class="badge badge-important">6</span>
<span class="badge badge-info">8</span>
<span class="badge badge-inverse">10</span>
</body>
</html>
All these changes lead me a bit closer to my goal. However the badges of the bootstrap is displayed but there is no color being displayed. Everything is grey with white text =[ I'm not sure if the other features work as well. I shall try them. Thank you again for all the help! much appreciated!
Development Server:
Leave STATIC_ROOT
empty.
Make a change to STATICFILES_DIRS
STATICFILES_DIRS = (
'/home/bradford/Development/Django/public_pictures/static',
)
Run ./manage.py collectstatic
Should work.
这篇关于引导文件404 Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!