首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django没有渲染Glyphicons

Django没有渲染Glyphicons
EN

Stack Overflow用户
提问于 2014-09-28 16:38:07
回答 1查看 3.4K关注 0票数 2

网格图标在我的开发服务器中呈现为空矩形。

设置

代码语言:javascript
复制
from unipath import Path  

BASE_DIR = Path(__file__).ancestor(2)                                   
STATICFILES_DIRS = (BASE_DIR.child("static", "static_dirs"), )        
STATIC_URL = '/static/'       

模板

代码语言:javascript
复制
{% load staticfiles %}
<span class="glyphicon glyphicon-heart"></span> 
<span class="glyphicon glyphicon-calendar"></span>  

bootstrap.css/bootstrap.min.css

代码语言:javascript
复制
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
    url('../fonts/glyphicons-halflings-regular.woff') format('woff'), 
    url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), 
    url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');

urls

代码语言:javascript
复制
urlpatterns = patterns('',
    url(regex = r'^$',
        view = 'tesglyph.views.testglyph'),
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

当我加入

base.html

代码语言:javascript
复制
<head>
(...)
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css"     rel="stylesheet">(...)
</head>

我得到了心,但没有日历!

我该怎么解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-28 16:48:07

这似乎太难了,你考虑过像django-bootstrap3这样的东西吗?

所有需要的都是-

代码语言:javascript
复制
{% load bootstrap3 %}

...

{% bootstrap_icon "heart" %}

请注意,此解决方案意味着您只在模板中编写代码,从而节省了大量的麻烦。用要显示的引导图标名称替换heart。就这样。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26087134

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档