Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django tables2 and css

I've got a table in a view which doesn't render css. I suppose it's a stupid error but I can't find any solution on my way :(

The 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})

The Template :

{% 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>

Sorry for my poor english and noobie question.

like image 359
Nicolas Pierrot Avatar asked Mar 22 '23 10:03

Nicolas Pierrot


1 Answers

For anyone who has the same problem, don't forget the attrs...

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")
like image 143
Nicolas Pierrot Avatar answered Apr 06 '23 02:04

Nicolas Pierrot