python - Django_tables2 : CSS isn't working even though it's registered

标签 python html css django

我复制了 django_tables2 网站示例中显示的具有 paleblue 类的 screen.css。

我将它放在我的应用程序中的 static/css 文件夹中,当我从我的 .html 调用它时,它会找到它。在标题中,我放置了以下内容:

<link rel="stylesheet" href="{{ STATIC_URL }}css/screen.css" />

现在,在我的 tables.py 模块中我有这个:

import django_tables2 as tables
class TipPredmetaTable(tables.Table):
class Meta:
    model = models.TipPredmeta
    attrs = {'class': 'paleblue'}

在我的 views.py 中我有这个:

def tippredmeta(request):
    queryset = TipPredmeta.objects.all()
    table = TipPredmetaTable(queryset)
    RequestConfig(request).configure(table)
    return render_to_response('azuriranje/tabela.html', {"table": table}, context_instance=RequestContext(request))

当我在 Mozzila 中打开页面并按下 Ctrl+U 时,我可以清楚地看到以下内容:

<div class="table-container"><table class="paleblue"><thead>&#32;<tr>...

我的 .html 与 django_tables2 网站上的完全一样,我的 STATIC_URL 已定义,staticfiles 应用程序已启用。我做错了什么?

最佳答案

好的,在通过网络和我的代码进行更广泛的搜索后,我已经弄明白了。看来我忘记将 'django.core.context_processors.static' 放入 TEMPLATE_CONTEXT_PROCESSOR 是我问题的根源。

关于python - Django_tables2 : CSS isn't working even though it's registered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20019166/

相关文章:

Python-使用列表作为函数参数

python - 对于大数据(通过 stdin.readlines())在 python 中比 map() 更快的方法

html - 如何水平对齐代表表格行的div

html - MySQL 每日预约安排架构

jquery - 圆形按钮 CSS3 悬停不起作用

html - Mat-icon 不在其 div 中心

css - 将空白限制为两行换行

python - numpy.fft.fft 中参数 n 的影响是什么

python - 使用 python 2.7 从 block 中的文件进行 base64 编码、解码

css - 将 div float 在(绝对定位?)背景 div(或图像)上