Add col-X classes to HTML table on custom query page

This commit is contained in:
Simon Willison 2018-04-19 08:36:14 -07:00
commit e2750c7cc0
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
2 changed files with 4 additions and 3 deletions

View file

@ -79,6 +79,7 @@ class RenderMixin(HTTPMethodView):
**context, **{ **context, **{
'app_css_hash': self.ds.app_css_hash(), 'app_css_hash': self.ds.app_css_hash(),
'select_templates': select_templates, 'select_templates': select_templates,
'zip': zip,
} }
}) })
) )

View file

@ -44,14 +44,14 @@
<table> <table>
<thead> <thead>
<tr> <tr>
{% for column in columns %}<th scope="col">{{ column }}</th>{% endfor %} {% for column in columns %}<th class="col-{{ column|to_css_class }}" scope="col">{{ column }}</th>{% endfor %}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for row in rows %} {% for row in rows %}
<tr> <tr>
{% for td in row %} {% for column, td in zip(columns, row) %}
<td>{% if td == None %}{{ "&nbsp;"|safe }}{% else %}{{ td }}{% endif %}</td> <td class="col-{{ column|to_css_class }}">{% if td == None %}{{ "&nbsp;"|safe }}{% else %}{{ td }}{% endif %}</td>
{% endfor %} {% endfor %}
</tr> </tr>
{% endfor %} {% endfor %}