-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
239 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{% load django_tables2 %} | ||
{% load i18n %} | ||
{% block table-wrapper %} | ||
<div class="table-container"> | ||
{% block table %} | ||
<table {% if table.attrs %} {{ table.attrs.as_html }}{% else %}class="table"{% endif %}> | ||
{% block table.thead %} | ||
{% if table.show_header %} | ||
<thead class="thead-default"> | ||
<tr> | ||
{% for column in table.columns %} | ||
{% if column.orderable %} | ||
<th {{ column.attrs.th.as_html }}><a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}">{{ column.header }}</a></th> | ||
{% else %} | ||
<th {{ column.attrs.th.as_html }}>{{ column.header }}</th> | ||
{% endif %} | ||
{% 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 scope="row" {{ row.attrs.as_html }}> | ||
{% for column, cell in row.items %} | ||
<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 %} | ||
{% if table.empty_text %} | ||
{% block table.tbody.empty_text %} | ||
<tr><td colspan="{{ table.columns|length }}">{{ table.empty_text }}</td></tr> | ||
{% endblock table.tbody.empty_text %} | ||
{% endif %} | ||
{% endfor %} | ||
</tbody> | ||
{% endblock table.tbody %} | ||
{% block table.tfoot %} | ||
{% if table.has_footer %} | ||
<tfoot> | ||
<tr> | ||
{% for column in table.columns %} | ||
<td {{ column.attrs.tf.as_html }}>{{ column.footer }}</td> | ||
{% endfor %} | ||
</tr> | ||
</tfoot> | ||
{% endif %} | ||
{% endblock table.tfoot %} | ||
</table> | ||
{% endblock table %} | ||
|
||
{% if table.page and table.paginator.num_pages > 1 %} | ||
{% block pagination %} | ||
<nav aria-label="Table navigation"> | ||
<ul class="pagination justify-content-center"> | ||
{% if table.page.has_previous %} | ||
{% block pagination.previous %} | ||
<li class="page-item"> | ||
<a href="{% querystring table.prefixed_page_field=table.page.previous_page_number %}" class="page-link"> | ||
<span aria-hidden="true">«</span> | ||
{% trans 'previous' %} | ||
</a> | ||
</li> | ||
{% endblock pagination.previous %} | ||
{% endif %} | ||
|
||
{% for p in table.page|table_page_range:table.paginator %} | ||
<li class="page-item{% if table.page.number == p %} active{% endif %}"> | ||
<a class="page-link" {% if p != '...' %}href="{% querystring table.prefixed_page_field=p %}"{% endif %}> | ||
{{ p }} | ||
</a> | ||
</li> | ||
{% endfor %} | ||
|
||
{% if table.page.has_next %} | ||
{% block pagination.next %} | ||
<li class="page-item"> | ||
<a href="{% querystring table.prefixed_page_field=table.page.next_page_number %}" class="page-link"> | ||
{% trans 'next' %} | ||
<span aria-hidden="true">»</span> | ||
</a> | ||
</li> | ||
{% endblock pagination.next %} | ||
{% endif %} | ||
</ul> | ||
</nav> | ||
{% endblock pagination %} | ||
{% endif %} | ||
</div> | ||
{% endblock table-wrapper %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
-e .. | ||
django-bootstrap3==9.1.0 | ||
django-bootstrap4==0.0.5 | ||
django-debug-toolbar==1.9.1 | ||
django-filter==1.1.0 | ||
tablib<0.11.99 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,7 @@ | |
|
||
'django_filters', | ||
'bootstrap3', | ||
'bootstrap4', | ||
'django_tables2', | ||
'debug_toolbar', | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{% load static %} | ||
{% load render_table from django_tables2 %} | ||
{% load bootstrap4 %} | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>django_tables2 with bootstrap 4 template example</title> | ||
{% bootstrap_css %} | ||
|
||
</head> | ||
<body> | ||
<div class="container"> | ||
{% block body %} | ||
|
||
<h3>django_tables2 with <a href="https://getbootstrap.com/docs/4.0/">bootstrap 4</a> template example</h3> | ||
|
||
<a href="https://getbootstrap.com/docs/4.0/content/tables/">Bootstrap 4 - tables docs</a> | ||
<a href="https://getbootstrap.com/docs/4.0/components/pagination/">Bootstrap 4 - pagination docs</a> | ||
|
||
<div class="row"> | ||
{% if filter %} | ||
<div class="col-sm-10"> | ||
<form action="" method="get" class="form form-inline"> | ||
{% bootstrap_form filter.form layout='inline' %} | ||
{% bootstrap_button 'filter' %} | ||
</form> | ||
</div> | ||
{% endif %} | ||
<div class="col-sm-10"> | ||
{% render_table table %} | ||
</div> | ||
</div> | ||
{% endblock %} | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters