【问题标题】:How do I change the font size and / or font family when using django-tables2?使用 django-tables2 时如何更改字体大小和/或字体系列?
【发布时间】:2022-01-05 17:45:25
【问题描述】:

表定义:

''' 将 django_tables2 导入为表 从 django_tables2.utils 导入 A 从 cliente.models 导入 Cliente

类 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"}

'''

模板

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

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

    {% render_table table %}   

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

结果对我客户的口味来说有点太大了。感谢您的帮助。

【问题讨论】:

    标签: python css django django-tables2


    【解决方案1】:

    在此处将自定义类添加到您的表中:

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

    然后使用<style> 块向您的模板添加样式:

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

    【讨论】:

      【解决方案2】:

      太棒了!!它马上就奏效了!

      【讨论】:

      • 嗨@H。道丁!答案很有效:)。请接受有帮助的答案。它可以激励人们为所提出的帖子发布答案。
      • 真的很抱歉回答迟了
      猜你喜欢
      • 2015-04-08
      • 1970-01-01
      • 2011-05-26
      • 1970-01-01
      • 2011-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多