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, **{
'app_css_hash': self.ds.app_css_hash(),
'select_templates': select_templates,
'zip': zip,
}
})
)

View file

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