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

django-tables2: use request user in render method

I'm using djnago-tables2 to display data from my event model. I need to get the current request user into the render method of the table (to further call a model function to get the response of the current user). How can i do this? My Model class…
welworx
  • 370
  • 2
  • 14
4
votes
2 answers

How to change a django_tables2 table dynamically on ajax request

I want my django_tables2 table to be able to add new rows at the top as new data comes in from the server (possibly by polling, or possibly via a push). I don't want to do a server page refresh, just scroll the existing rows down and add the new…
Carilda
  • 161
  • 2
  • 12
4
votes
1 answer

Django: In django-tables2 how to modify the way URLField gets rendered

I'm new to Django and I'm building a web-page which displays model's info in a table format. I discovered for myself a very useful library - django-tables2 which makes building html tables very simple. However, I am not able to figure out how to…
user2726997
4
votes
2 answers

Django: django-tables2 Changing default sort behaviour

I'm experimenting with django-tables2. I've created a test site that displays a column of dates (created by timezone.now()). By default, the dates are ordered Oldest->Newest. If I click on column header, the dates are displayed in reverse order (the…
Dirty Penguin
  • 4,212
  • 9
  • 45
  • 69
4
votes
1 answer

Django tables2 and css

I've got a table in a view which doesn't render css. I suppose it's a stupid error but I can't find any solution on my way :( The View : class ContactsTable(tables.Table): selection = tables.CheckBoxColumn(accessor="id") class Meta: …
Nicolas Pierrot
  • 143
  • 1
  • 7
4
votes
2 answers

how to add 2 extra LinkColumns in a model based Table with django_tables2 in django 1.5

I am trying to do a table with 2 linkColumns with django-tables2, the links include the pk of the model class. The links point to the Edit and Delete forms. models.py from django.db import models from django.utils.translation import ugettext_lazy…
4
votes
2 answers

How to render table from custom sql with django-tables2?

I'm working with Django and django-tables2 to make a nice representation of sql queries in a web-interface. I have a legacy sql code which is very-very complicated to define it throught standard models.py. The question is: how can i render a table…
alexeyhaidamaka
  • 168
  • 1
  • 9
4
votes
2 answers

django-tables2 linkColumn external url

I have 2 model attributes - model.name and model.url I need to create a linkColumn that column name = model.name and link to the url specified in model.url Is it possible to achieve such thing? thanks
DjangoPy
  • 855
  • 1
  • 13
  • 29
4
votes
3 answers

Django-tables2 does not sort

I display a database table using django-tables2. All appears OK, but clicking on the column headers does not sort by that column. The headers are clickable, but in their html has no url text in it, e.g.:
John Peters
  • 1,177
  • 14
  • 24
3
votes
2 answers

Exporting Django models to Excel (different sheets) using Django-tables2

I've checked django-tables2 documentation, however I haven't find an easy way to export models to different sheets in Excel. To make it simple, let's suppose I have two different models: Sales and Products. I would like to export an excel document…
quechua685
  • 126
  • 1
  • 8
3
votes
1 answer

How do I fitler the intial table using django-tables2 and django-filter?

I'm using django-tables2 and django-filter to list employees from a model. I'm having trouble filtering the initial table rendered. It's including all records. I want the initial table to only include employees where status=1. Then, have the…
Shaun Stacey
  • 33
  • 1
  • 3
3
votes
1 answer

Django tables 2 - how do i change the queryset of the model i am displaying?

I'm trying to display all model objects after a get request in a table using django-tables2. It's currently displaying all and I can't figure out how to filter the queryset based on a model pk in my view: views.py class ViewJob(LoginRequiredMixin,…
trouselife
  • 971
  • 14
  • 36
3
votes
1 answer

How to change button inside a django table to text after it has been accessed

So, this is my first project with Django, and for the first time I am using the Django-Tables2. I have a Django table with three columns, last column contains add button for each row which when clicked takes me to another page where I can select…
3
votes
5 answers

Django/django-tables2 html table on row click to edit form

sorry this post may be messy not sure how do explain what I am looking for very well but here goes nothing. I have a Django App and using django-table2 to print a data model to a table, the next thing I am looking to do it when the user clicks on…
Kieron Gilbey
  • 41
  • 1
  • 1
  • 4
3
votes
2 answers

how to display images by using django-tables2

I am new to Django-tables2, and I've searched around for this but haven't had much luck so looking for a bit of help. I am trying to display images in the cells of django-tables2; however, I only have the links to the images on my page and need to…
Fiona Xu
  • 31
  • 3