加载引导加载程序时出错,使用django(未找到css) [英] Error on loading bootstrap loader, using django (not found the css)

查看:2885
本文介绍了加载引导加载程序时出错,使用django(未找到css)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的django和python,创建一个测试项目,工作得很好,直到尝试改变设计像css,js和一些img。我安装了bootstrap,当我上传的三个文件,css,js和img,页面找不到我的css文件和其他。在我的服务器上显示此消息:


[30 / Jan / 2014 11:19:15]GET / static / HTTP / 1.1 404 1614
[30 / Jan / 2014 11:19:34]GET /static/css/bootstrap.css HTTP / 1.1404 1655


我尝试ti从开发人员部分找到跳转到此页面的bss页面:
未找到页面(404)
请求方法:
GET
请求URL:



localhost:8000 / static / css / bootstrap.css'css / bootstrap.css'找不到
错误,因为您的Django设置文件中有DEBUG = True。将其更改为False,Django将显示标准的404页面。



下面是base.html上的css文件链接。
href =/ static / css / bootstrap.css



你能告诉我这里有什么问题吗? >

感谢
Dilshad

解决方案

如果你有css文件夹静态文件夹
,您的settings.py中有这样的文件:

  STATIC_URL ='/ static /'
STATICFILES_DIRS =(
os.path.join(BASE_DIR,static),
'/ var / www / static /',



您在INSTALLED_APPS中有此项:

  'django.contrib.staticfiles',

然后在您的模板中使用:

  {%load staticfiles%} 
< link rel =stylesheettype =text / csshref ={%static css / bootstrap.css%}>

详情:
https://docs.djangoproject.com/en/dev/howto/static-files/


I am new with django and python, have create a test project which works well until the point try to change the design like css, js and some img. I installed bootstrap as well, when I upload the three files, css, js and img, The page can not find my css file and others. On my server display this message:

[30/Jan/2014 11:19:15] "GET /static/ HTTP/1.1" 404 1614 [30/Jan/2014 11:19:34] "GET /static/css/bootstrap.css HTTP/1.1" 404 1655

I tried ti find the css page from developer section on firework which jump to this page: Page not found (404) Request Method: GET Request URL:

localhost:8000/static/css/bootstrap.css 'css/bootstrap.css' could not be found You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

And below is the link on base.html to the css files. href="/static/css/bootstrap.css"

Could you please give me an idea what is wrong here, I do appreciate?

Thanks Dilshad

解决方案

if you have your css folder in static folder and you have this in your settings.py:

STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
'/var/www/static/',
)

and you have this in INSTALLED_APPS:

'django.contrib.staticfiles',

then use this in your template:

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

more details: https://docs.djangoproject.com/en/dev/howto/static-files/

这篇关于加载引导加载程序时出错,使用django(未找到css)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆