Skip to content

Commit

Permalink
Fixes jieter#335
Browse files Browse the repository at this point in the history
  • Loading branch information
ralgozino committed Aug 9, 2016
1 parent 6adadd9 commit d51e4c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions django_tables2/templates/django_tables2/bootstrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

<div class="table-container">
{% block table %}
<table class="table table-bordered table-striped"{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
<table {% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
{% block table.thead %}
{% if table.show_header %}
<thead>
<tr>
{% for column in table.columns %}
Expand All @@ -19,18 +20,19 @@
{% endfor %}
</tr>
</thead>
{%endif%}
{% endblock table.thead %}
{% block table.tbody %}
<tbody>
{% for row in table.page.object_list|default:table.rows %} {# support pagination #}
{% block table.tbody.row %}
<tr {{ row.attrs.as_html }}>
{% for column, cell in row.items %}
<td {{ column.attrs.td.as_html }}>{{ cell }}</td>
<td {{ column.attrs.td.as_html }}>{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}</td>
{% endfor %}
</tr>
{% endblock table.tbody.row %}
{% empty %}
{% empty %}
{% block table.tbody.empty_text %}
{% trans "no results" as table_empty_text %}
<tr>
Expand Down Expand Up @@ -66,6 +68,12 @@
<li class="cardinality">
{% blocktrans with table.page.number as current and table.paginator.num_pages as total %}Page {{ current }} of {{ total }}{% endblocktrans %}
</li>
{% block pagination.cardinality %}
<li class="cardinality">
{% if total != count %}{% blocktrans %}{{ count }} of {{ total }}{% endblocktrans %}{% else %}{{ total }}{% endif %} {% if total == 1 %}{{ table.data.verbose_name }}{% else %}{{ table.data.verbose_name_plural }}{% endif %}
</li>
{% endblock pagination.cardinality %}
</li>
{% if table.page.has_next %}
<li class="next">
<a href="{% querystring table.prefixed_page_field=table.page.next_page_number %}" class="btn btn-default">
Expand Down
1 change: 1 addition & 0 deletions example/app/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class BootstrapTable(tables.Table):
class Meta:
model = Person
template = 'django_tables2/bootstrap.html'
attrs = {'class': 'table table-bordered table-striped'}


class PersonTable(tables.Table):
Expand Down

0 comments on commit d51e4c0

Please sign in to comment.