django-tables2

Django-Tables2 LinkColumn link doesn't work

倖福魔咒の 提交于 2019-12-23 04:31:30
问题 I think I'm missing something obvious here, but I've been stuck at this for so long, I had to post the question. Link to screenshot When I click on the link generated in LinkColumn of django-tables2, it redirects back to the same page. Here's my code: urls.py: urlpatterns = patterns('', url(r'^$', views.index, name='index'), url(r'admin', views.admin, name='admin'), url(r'admin/edit/(?P<pk>\d+)/', views.bug_edit, name='bug_edit'), url(r'admin/delete/(?P<pk>\d+)/', views.bug_delete, name='bug

Is it possible to apply a template tag to a <td> when using django-tables2?

落花浮王杯 提交于 2019-12-22 07:01:39
问题 I am using django-tables2 to create my table for me. I need to apply a template tag to each of the cells () in one of the columns. It seems like alot of extra effort to go through and create a custom table layout just to apply the template tag to the one column. Is there a way to do this in django-tables2? Update: I may not have explained what I'm looking for well enough. I don't believe that will work. My code: class CombineTable(tables.Table): build_no = tables.LinkColumn('run', args=[A(

django-tables2 specify different properties for different rows

笑着哭i 提交于 2019-12-22 04:55:33
问题 I would like to create a table with django-tables2 such that different rows have different properties. By default I get either <tr class="odd"> or <tr class="even"> How can I specify my own class for some of the rows? Similarly, if I have a CheckBoxColumn and I specify some data for this column, it goes into the value : <input type="checkbox" name="col" value="123"/> This is great for figuring out which checkbox was checked. However, how can I set some checkboxes as checked when the table is

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

走远了吗. 提交于 2019-12-22 04:25:09
问题 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 ClientsTable(tables.Table): class Meta: model = Client attrs = {"class": "paleblue", "orderable":"True", "width":"100%"} fields = ('name',) def __init__(self, *args, **kwargs): super(ClientsTable, self).__init__(*args, **kwargs) self.counter = itertools

Request Object Passed to Django-Tables2 Tables Class

試著忘記壹切 提交于 2019-12-20 06:24:36
问题 Lets say that we have two models: ModelA and ModelB. I will use Django-Tables2 to create a table out of these models. In tables.py you could have two separate table classes (below). from .models import ModelA, ModelB import django_tables2 as tables class ModelATable(tables.Table): class Meta: #some basic parameters model = ModelA #the template we want to use template_name = 'django_tables2/bootstrap.html' class ModelBTable(tables.Table): class Meta: #some basic parameters model = ModelB #the

Request Object Passed to Django-Tables2 Tables Class

匆匆过客 提交于 2019-12-20 06:24:18
问题 Lets say that we have two models: ModelA and ModelB. I will use Django-Tables2 to create a table out of these models. In tables.py you could have two separate table classes (below). from .models import ModelA, ModelB import django_tables2 as tables class ModelATable(tables.Table): class Meta: #some basic parameters model = ModelA #the template we want to use template_name = 'django_tables2/bootstrap.html' class ModelBTable(tables.Table): class Meta: #some basic parameters model = ModelB #the

Django - List of Dictionaries to Tables2

泪湿孤枕 提交于 2019-12-18 09:44:06
问题 afraid I'm a Newbie when it comes to Django. I have a list of Dictionaries which I want to use to populate a Tables2 table. I don't know how to adapt the list of Dicts to work in Table2 :( The website suggests: import django_tables2 as tables data = [ {"name": "Bradley"}, {"name": "Stevie"}, ] class NameTable(tables.Table): name = tables.Column() table = NameTable(data) I can't figure this out! Also, I will be using this view with many different sets of data and so my keys will change over

Django Tables - Column Filtering

不羁岁月 提交于 2019-12-17 16:35:08
问题 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. 回答1: A little late answer but anyway ... I also couldn't find any appropriate documentation for column filtering. There are many methods to do it: A. By hand : I add a form containing the fields I'd like to filter with and then I do something like this in my

how to load unstructured non-queryset data with django-tables2

浪子不回头ぞ 提交于 2019-12-13 07:53:12
问题 I'd like to use django-tables2 to display data from a spreadsheet or csv file. The data will always be dynamic so I need a way of dynamically adding columns to my django-tables2 table. From the documentation there seems to be no way of doing this. Any ideas? 回答1: In Python, you can use type to construct classes dynamically. Let's use the example from the docs, which defines a table with one column, name . import django_tables2 as tables data = [ {"name": "Bradley"}, {"name": "Stevie"}, ]

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

做~自己de王妃 提交于 2019-12-13 00:14:48
问题 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 = models.PositiveIntegerField() title = models.CharField(max_length=1024) content = models.TextField(null=True, blank=True) According to the docs, render_foo won't be executed if it is considered an empty value . My requirement is that foo is not found in the Model. How can I implement the