我在 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/