Questions tagged [django-tables2]

django-tables2 simplifies the task of turning sets of data into HTML tables.

Native support for pagination and sorting. It does for HTML tables what django.forms does for HTML forms.

  • Any iterable can be a data-source, but special support for Django querysets is included.
  • The builtin UI does not rely on JavaScript.
  • Support for automatic table generation based on a Django model.
  • Supports custom column functionality via subclassing.
  • Pagination.
  • Column based table sorting.
  • Template tag to enable trivial rendering to HTML.
  • Generic view mixin.

Related links:

628 questions
2
votes
2 answers

How do I use django_tables2 with a filter?

I'm displaying data on a webpage, and I would like to migrate this code to use the table I created in tables.py. I can't figure out how to do it without breaking the filter. views.py def PlatListView(request): queryset =…
2
votes
1 answer

django tables 2 - delete column and delete_item for inherited tables

I want to have one abstract function for all my tablelists (one for each model) and (one delete_item) function in view. I don't know how to make the delete (column in this table) and pass the model to the delete_item function in the view Tables.py …
2
votes
2 answers

django tables2 display sort arrows on header

I'm using django tables2, and I think it would be useful to have up and down arrows on header columns to indicate the current sorting order, especially when the default sort is on a column other than the first. Tried playing with CSS but no luck,…
cdm
  • 719
  • 2
  • 10
  • 22
2
votes
1 answer

Django-filter and Django-tables2 filter with ModelChoice values not filtering

I have a filter using ModelChoiceFilter from a DB column called 'semanas' (Weeks) and the values that are stored there at the moment are: 2020-W5 2020-W6 I have the data being displayed in a table (django-tables2), when I select any of these 2…
Jorge López
  • 489
  • 3
  • 17
2
votes
1 answer

How to use same same django_filters.CharFilter field for two separate fields

So, basically I have a FilterSet I am using with django-tables2. Now I need to use have a single char field which should search two separate fields from the Model. For example: ip_addr = django_filters.CharFilter(lookup_expr='icontains') virtual_ip…
Amar C
  • 374
  • 5
  • 17
2
votes
1 answer

Is it right that django migrations are running the filter of django tables2 module before running the migrations?

I have a semi large software. At one point I included tables2 into that project and started to work with it. I the filter.py file I included some basic Model filtering. Now if I delete my database and try to run a fresh migrations I get the error,…
Dominic M.
  • 273
  • 1
  • 5
  • 15
2
votes
0 answers

Django_select2 : How to filter ModelSelect2Widget queryset with a request data? (Django_tables2 + Django_filter +Django_select2 )

I use django_tables2 with django_filter according to django_tables2 tutorial: #views.py from django_filters.views import FilterView from django_tables2.views import SingleTableMixin class FilteredCarListView(SingleTableMixin, FilterView): …
2
votes
1 answer

How to export .csv with Django-Tables2?

I'm trying to export a table in .csv with Django-Tables2, I've done the following so far. tables.py class ClientTable(ColumnShiftTable): class Meta: model = Client sequence = ('id', 'nome_razao_social', 'cpf', 'cnpj',…
Rafael
  • 197
  • 11
2
votes
2 answers

How to define in the same class based view two or more tables with django_tables2

I am trying unsuccessfully to define two different tables in my class based view with MultiTableMixin of django_tables2. The tables are refering to the same model. tables.py class PrescriptionsTable(tables.Table): class Meta: #define the…
gtopal
  • 544
  • 1
  • 9
  • 35
2
votes
2 answers

Django_tables2 with Edit and Delete buttons. How to do it properly?

I'm building an app that lists, sorts, updates and deletes objects. How can I properly add edit and/or delete buttons to django-tables2 table render? Python version: 3.7 and Django version: 2.1.7 are used. I have tried multiple ways and searched on…
Aleksa Terzic
  • 35
  • 1
  • 10
2
votes
1 answer

Link column with a static text using django-tables2

I cannot find a replacement for the LinkColumn in the new versions of django-tables2. Author states that LinkColumn is deprecated and shouldn't be used. But the new linkify solution is poorly documented and doesn't have all the features of the old…
Eugene Morozov
  • 15,081
  • 3
  • 25
  • 32
2
votes
1 answer

How to get linkify to take you to a detail view from a django table?

I'm trying to create link from a django-tables2 column to a 'detail view' of the object. For instance, I have a column of health providers and I want a user to be able to click on it and see specific information for the health provider from a django…
user10931108
2
votes
2 answers

How to apply Datatables plugin to a rendered django-tables2?

Problem implementing of Datatables plugin to a 'Django-tables2' rendered table. I'm beginner at Django; I'm working on an app that shows data upload to the database (postgresql), looking for solution to the high time to render the table with many…
Leonel Garcia
  • 79
  • 1
  • 8
2
votes
2 answers

django how to get context item by name

I am rendering a few tables which I add to the context in the view from .models import MyModel from .tables import MyModelTable def index(request): context = dict(all_tables=[]) template = 'mypage/index.html' for x in some_list: …
chrise
  • 4,039
  • 3
  • 39
  • 74
2
votes
1 answer

Reduce large number to intword in Django without editing template

I am developing a web application that displays an html table using django, django-tables2 and Bootstrap4. I have a column AUM which contains very large numbers (up to billions). In my models.py the corresponding model uses a models.Interfield() for…
deepNdope
  • 179
  • 3
  • 14