django-tables2

'django.template.context_processors.request' issue with django-tables2 and django-admin-tools

你离开我真会死。 提交于 2019-12-12 17:17:23
问题 I'm having an issue when trying to render a PDF through xhtml2pdf in Django(1.10.4) when using django-admin-tools(0.8.0) & django-tables2(1.5) together. I've done enough reading to understand the basis of what's going on but have not idea how to fix it. I think it's got something to do with the django-admin-tools custom loaders. Link to the exception I'm getting from django-tables. This SO question led me to asking a question. The gist of what I'm trying to do is create a custom Admin 'action

django-tables2 header row urls wrong…can't sort

筅森魡賤 提交于 2019-12-11 14:59:46
问题 I can't figure out how to solve this issue about sorting my table: table is rendered at this url: 127.0.0.1:8000/ip_teams/ but when I click on the name of the column to sort the table, url became: 127.0.0.1:8000/?sort=name it excludes the "ip_teams/" path. This is my view: class FoundationIPTypeList(SingleTableView): model = tracker_models.FoundationIPType table_class = tables.FoundationIPTypeTable this is my table: class FoundationIPTypeTable(django_tables.Table): class Meta: model =

Django-tables2 column total

雨燕双飞 提交于 2019-12-11 01:05:21
问题 I'm trying to sum up all values from column using this documentation, but footer doesn't show up. I'm I missing something? models.py class Mokejimai(models.Model): id = models.AutoField(primary_key=True) nr = models.IntegerField(verbose_name='Mok. Nr.') data = models.DateField(verbose_name='Kada sumokėjo') suma = models.FloatField(verbose_name='Sumokėta suma') skola_pagal_agnum = models.FloatField(verbose_name='Skola pagal Agnum') date_entered = models.DateTimeField(auto_now_add=True, auto

'unicode' object has no attribute '_meta'

蓝咒 提交于 2019-12-10 23:23:45
问题 I am trying to create a view in which the user selects an option from a drop down menu, submits it, and then some data is returned. Specifically, they will select from models in the database and have returned all of the instances of that class. I am using django-tables2 to output the data so that it is sortable, but this is my sticking point. Views.py def output_form(request): results = None if request.GET.get('browse'): selection = request.GET.get('browse') class ModelTable(tables.Table):

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

房东的猫 提交于 2019-12-10 15:24:58
问题 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 from custom sql query using django-tables2? 回答1: The docs on populating a table with data show how you can create a table with a list of dictionaries as the input data. import django_tables2 as tables data = [ {"name": "Bradley"}, {"name": "Stevie"}

django-tables2 linkColumn external url

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 10:27:51
问题 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 回答1: You can use TemplateColumn to achieve it. Your tables.py should look something like this # yourapp/tables.py import django_tables2 as tables from yourapp.models import yourmodel class YourTable(tables.Table): name = tables.TemplateColumn('<a href="{{record.url}}">{{record.name}}</a>') class

django-tables2 add button per row

烈酒焚心 提交于 2019-12-09 16:55:29
问题 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 them in advance. What I need, is to have one button per row that loads the retrieved object inside the fields of a form. I render the table with the default way: {% load render_table from django_tables2 %} {% render_table table %} When I try to

Django-tables2: Change text displayed in column title

你。 提交于 2019-12-09 03:32:36
问题 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) numberofissues = models.BigIntegerField() class Meta: managed=False db_table = 'stability_dashboard' I have also managed to display data in a table using the boiler plate code from the example: #tables.py class DashboardTable(tables.Table): class Meta: model =

Displaying Page Numbers with django-tables2

送分小仙女□ 提交于 2019-12-08 21:47:44
问题 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 page numbers using django-tables2 below my table? What I'd like to be able to display is a horizontal list of page numbers that the user can click. Thanks in advance. 回答1: you need to create a custom page rendering template - you don't need to

django-tables2 linkColumn accessor

≯℡__Kan透↙ 提交于 2019-12-08 18:15:26
I have been using django-tables2 which I like, but i run into some problems I am trying to make a table in which cells link out to a different table, or an outside link the example in the documentation is : models.py class Person(models.Model): name = models.CharField(max_length=200) urls.py urlpatterns = patterns('', url('people/(\d+)/', views.people_detail, name='people_detail') ) tables.py from django_tables.utils import A # alias for Accessor class PeopleTable(tables.Table): name = tables.LinkColumn('people_detail', args=[A('pk')]) I have been trying to use this to no success... What would