How do I change the font size and / or font family when using django-tables2?

Viewed 259

Table definitions:

''' import django_tables2 as tables from django_tables2.utils import A from cliente.models import Cliente

class BrowseCliente(tables.Table):

nome = tables.Column(verbose_name='Nome',orderable=True)
tipo = tables.Column(verbose_name='Tipo',orderable=False)
cidres = tables.Column(verbose_name='Cidade',orderable=False)
estado = tables.Column(verbose_name='UF',orderable=False)
celular = tables.Column(verbose_name='Celular',orderable=False)
email = tables.Column(verbose_name='E-Mail',orderable=False)
dddres = tables.Column(verbose_name='DDD Res',orderable=False)
foneres = tables.Column(verbose_name='Fone Res',orderable=False)

class Meta:

    model = Cliente 
    template_name = "django_tables2/bootstrap4.html"
    fields = ('nome',
              'tipo',
              'cidres',
              'estado',
              'celular',
              'email',
              'dddres',
              'foneres')

    attrs = {"class": "table table-striped"}

'''

Template

{% extends 'base.html' %}
{% load render_table from django_tables2 %}
{% block content %}

    {% include 'partials/_menu4.html' %}

    {% render_table table %}   

    {% include 'partials/_footer.html' %}
    
{% endblock %}

The result is a little too big for my customer´s taste. I appreciate any help.

2 Answers

Add a custom class to your table here:

attrs = {"class": "table table-striped clients-table"}

And then add a style to your template with <style> block:

<style>
    .clients-table {
        font-size: 10pt;
    }

</style>

Wonderful!! It worked right away!

Related