css - Django tables2 和 css

标签 css django django-tables2

我在 View 中有一个表格,它不呈现 css。我想这是一个愚蠢的错误,但我找不到任何解决方案:(

View :

class ContactsTable(tables.Table):
    selection = tables.CheckBoxColumn(accessor="id")
    class Meta:
        model = Contact
        exclude = ("id", "civilite", "ad1", "ad2", "cp")
        sequence =("selection", "nom", "prenom", "comments", "telport", "telfixe", "email", "ville", "regime")

def ListContacts(request):
    table = ContactsTable(Contact.objects.all())
    RequestConfig(request).configure(table)

    return render(request, "contacts/contact_list.html", {'table': table})

模板:

{% load render_table from django_tables2 %}
<html>
    <head>
        <link rel="stylesheet" href="{{ STATIC_URL }}django_tables2/themes/paleblue/css/screen.css" />
    </head>
    <body>
        {% render_table table %}
    </body>
</html>

抱歉我的英语不好和菜鸟问题。

最佳答案

遇到同样问题的 friend ,不要忘记属性...

class ContactsTable(tables.Table):
    class Meta:
        model = Contact
        exclude = ("id", "civilite", "ad1", "ad2", "cp")
        sequence =("selection", "nom", "prenom", "comments", "telport", "telfixe", "email", "ville", "regime")
        --> attrs = {"class": "paleblue"} <--

    selection = tables.CheckBoxColumn(accessor="id")

关于css - Django tables2 和 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18822999/

相关文章:

python - Django-filter 和 Django-tables2 CheckBoxColumn 兼容性

javascript - 有没有办法让页面的所有 css 样式都静音?

javascript - 如何通过单击网页上的超链接来切换 Bootstrap 轮播中的元素?

css - 如何平衡具有可变高度的无序列表

python - 在特定日期后删除 django 模型实例的最佳方法

django - 在 Docker 上使用 Nginx、uWSGI 和 Postgres 配置 Django

html - CSS - 如何让 IE7 遵守最小宽度

python - 如何初始化表单中字段的值以在模板中进行编辑

django - 在 django-tables2 中,显示的行数取决于屏幕大小?

python - 使用 ajax 渲染 django 表