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
18
votes
2 answers

Django-tables2: How to use accessor to bring in foreign columns?

I've tried reading the docs and previous answers to this question without much luck. I've got a bunch of student-course registrations and I'd like to see some of those selected registrations in conjunction with some of the attributes of the…
user2709930
  • 183
  • 1
  • 1
  • 5
17
votes
4 answers

Django Tables - Column Filtering

I started using django-tables2 (which I can highly recommend from the first impression) and I m asking myself how to implement column filtering. I do not find the appropriate documentation for it, but I m sure it is somewhere out there.
Thomas Kremmel
  • 14,575
  • 26
  • 108
  • 177
17
votes
2 answers

django-tables2 add button per row

I'm rendering a queryset with django-tables 2 but since the table is rendered at once I can't manage the following: Firstly, I should mention that the number of rows of the table is different with each queryset so I don't know the exact number of…
marlen
  • 473
  • 6
  • 20
16
votes
1 answer

django-tables2 set of columns

How to tell django-tables2 which columns I would like to have in table? I know there is this Column attribute 'visible', which can be set to False. However I have a model with many fields, and would like to display just some of them, so writing a…
liepumartins
  • 464
  • 2
  • 6
  • 21
15
votes
4 answers

Error Using django-tables2 - Expected table or queryset, not 'str'

I am trying to create some tables for my application using django-tables2 and running into some difficulties. I am using Python 2.7, and Django 1.7. I am following the tutorial, and I ran into problems. I reach the point where I need to create a…
Ravi Mehta
  • 485
  • 1
  • 6
  • 15
13
votes
1 answer

Django-tables2: Change text displayed in column title

I am working with a MySQL view (Create View as Select ...) and have successfully manged to connect the view to a model like this: #models.py class Dashboard(models.Model): devenv = models.CharField(max_length=30, primary_key=True) …
Simon Shaw
  • 175
  • 1
  • 10
13
votes
2 answers

Disable pagination in django-tables2?

In django-tables2 I have a table which I do not want paginated. I have not specified pagination, as shown in the docs: table.paginate(page=request.GET.get('page', 1), per_page=25) The tables still paginate, presumably by default. The RequestConfig…
robline
  • 450
  • 4
  • 13
12
votes
1 answer

Non-queryset data ordering in django-tables2

The docs say: Where the table is backed by a model, the database will handle the ordering. Where this is not the case, the Python cmp function is used and the following mechanism is used as a fallback when comparing across different types: ... But…
John Peters
  • 1,177
  • 14
  • 24
9
votes
1 answer

Custom columns in django_tables2

I've had a search around for this but haven't had much luck so looking for a bit of help. I'm trying to add some extra columns to a table defined by a model, using function definitions in the model. Here's what my code looks like now: #…
DrBuck
  • 822
  • 7
  • 22
9
votes
2 answers

Django-tables2 - dynamically adding columns to table - not adding attrs to table tag in html

In my Django project I need to have tables which columns are dynamic and depend on what is in the database. So I found a solution in here and it works but with a little problem. Here's the class with a table I'm extending dynamically: class…
copinette
  • 113
  • 1
  • 5
9
votes
3 answers

Displaying Page Numbers with django-tables2

I'm currently displaying a dataset using django-tables2. The docs make no mention of this in particular, so I'm guessing this'll take probably some table overriding - but, I'm hopeful someone out there has already accomplished this. How can I render…
geogaddi
  • 565
  • 1
  • 8
  • 18
8
votes
4 answers

django-tables2 specify different properties for different rows

I would like to create a table with django-tables2 such that different rows have different properties. By default I get either or How can I specify my own class for some of the rows? Similarly, if I have a…
Sergey Orshanskiy
  • 6,794
  • 1
  • 46
  • 50
8
votes
2 answers

How to display rows of csv file in django?

I have a django app, which allows the user to upload a csv file, say a csv file of rankings of universities. I'd have to process the data that has been uploaded. For example, grey out any column which has string values and calculate the mean and…
user2237511
  • 1,089
  • 2
  • 13
  • 20
8
votes
3 answers

Modifying display format of DateTimes in django-tables2

I'm currently using django-tables2 to display a queryset of my model. One of the attributes of this model is a DateTimeField accurate to the millisecond which is being truncated to the minute in my table. I had previously manually implemented a…
Scott Quinton
  • 173
  • 1
  • 5
8
votes
3 answers

django-filter: extend filter query with request.user

I'm need to add an additional filter property (in the background) to a django-filter request. My Model: class Event(models.Model): name=models.CharField(max_length=254) location=models.ForeignKey(Place) …
welworx
  • 370
  • 2
  • 14
1
2 3
41 42