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
1 answer

django list model entry with multiple references

I have the following models which represent songs and the plays of each song: from django.db import models class Play(models.Model): play_day = models.PositiveIntegerField() source = models.CharField( 'source', …
ezdazuzena
  • 6,120
  • 6
  • 41
  • 71
2
votes
1 answer

Dynamic columns with SingleTableMixin and FilterView in Django

I'm using SingleTableMixin and FilterView in Django to render a filter form and table. On the basic level it works very well. Now, the table has as many columns as the model has fields (as it should), but I would like to render ONLY the columns for…
Oleksandr K
  • 119
  • 1
  • 10
2
votes
1 answer

Creating buttons in a column of a table created by django tables2

I have an extended admin model that creates action buttons. I have created a view to do pretty much the same thing. I have used tables2 and everything is just fine except for the actions column. I cannot find a way to generate the same button in the…
Ibo
  • 4,081
  • 6
  • 45
  • 65
2
votes
1 answer

django-tables2: Adding a new custom column not found in model

I have the following table: class TaskTable(tables.Table): def render_foo(self): raise Exception() class Meta: model = Task fields = ['foo'] for the following model: class Task(models.Model): priority =…
Tinker
  • 4,165
  • 6
  • 33
  • 72
2
votes
0 answers

Installing django-tables2 on heroku returning error: invalid command 'egg_info'

I'm trying to install django-tables2==1.21.1 on my Heroku dyno. Below is the error logs when I try to install it: ~ $ pip install django-tables2 Collecting django-tables2 Using cached django-tables2-1.21.1.tar.gz Complete output from command…
James Dernie
  • 158
  • 8
2
votes
1 answer

How to Conditionally render a Link Column with Django Tables 2?

With the following table when returning the BoundColumn it is plaintext and not html. class CarHistoryTable(tables.Table): edit = tables.LinkColumn( 'Car:update', kwargs={'pk': A('id')}, orderable=False, …
tread
  • 10,133
  • 17
  • 95
  • 170
2
votes
2 answers

Is it possible to custom django-tables2 template for a specific page in this case?

I'm using django-tables2 to render my data in tables in the template.. everything is rendered fine with pagination.. The Designer of our company wants to change the Display of data into blocks instead of simple table. the following picture may…
pietà
  • 760
  • 1
  • 11
  • 37
2
votes
1 answer

How to use djando-table2 with class based view to display data from multiple table?

models.py class DailyRecordManager(models.Manager): def get_query_set(self): qs = super(DailyRecordManager, self).get_query_set().order_by('date_organised') return qs class DailyRecord(models.Model): date_organised =…
Anuj Subedi
  • 42
  • 1
  • 8
2
votes
0 answers

Django ORM: Group By/Min and return full rows

I have a model table like this Table A Fields A, B, C, D, E (5 Fields) I want to group by field B and min by field C so in the end, i need to have a full queryset like A, B, C, D, E, Min(C)GroupBY(B) (6 Fields). I know about…
bezkos
  • 21
  • 1
  • 3
2
votes
1 answer

Django tables 2 creating custom calculated fields

def calculateTotalVists(days): total = 0 for i in days: total += i return total class ClientTable(tables.Table): class Meta: model = Client fields = ('id', 'name', 'phone') attrs = {'class': 'table…
user3080600
  • 1,309
  • 2
  • 11
  • 23
2
votes
1 answer

cell color Django-Tables2

Question: Where do I edit my django code to change the background color of individual cells based on business logic? In my views.py I have logic that captures the max value of column 'pts': def show_teams(request): reg =…
Krusaderjake
  • 479
  • 1
  • 7
  • 19
2
votes
2 answers

Link Column in Django Tables 2

I'm currently trying to add a Link column into a table that I have created already using Django tables 2. I'm using the following code from the documentation class PeopleTable(tables.Table): name = tables.LinkColumn('people_detail',…
noobCoder
  • 370
  • 1
  • 8
  • 18
2
votes
1 answer

Usage of Django-Filter on large tables along with DataTables2

I am using Django-Tables2 with following code to load the data on to data tables. sales_data = SalesTable(sale.objects.all().order_by('-time')) RequestConfig(request,paginate={'per_page': 50}).configure(sales_data) My Sales table has 1.4 million…
2
votes
1 answer

How to remove from django-tables2 a notation of the total row numbers in a pagination area

I cannot reproduce the same appearance of the table pagination format from the basic django-tables2 example. Here is my code Model: #models.py class Person(models.Model): name = models.CharField(verbose_name="full name",…
Mikhail Geyer
  • 881
  • 2
  • 9
  • 27
2
votes
1 answer

How to add GET parameters to django-tables2 LinkColumn

I am trying to set GET parameters on a LinkColumn based on Accessors with django-tables2. Let's say: urls.py urlpatterns = [ ... url(r'^rqGET$', views.rqGET, name='rqGET'), ... ] views.py def rqGET(request): #... do something with…
jmerkow
  • 1,811
  • 3
  • 20
  • 35