4

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.

Nicolas Pierrot
  • 143
  • 1
  • 7
  • Are you testing or in production? If you are in development, how are you serving your static files (have you done the following: https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-during-development) – Timmy O'Mahony Sep 16 '13 at 08:43
  • 2
    Forgot : attrs = {"class": "paleblue"} In Table Meta sublass :( – Nicolas Pierrot Sep 16 '13 at 08:45

1 Answers1

8

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")
Nicolas Pierrot
  • 143
  • 1
  • 7