Here is my table class:
--------------------------------------------
import django_tables as tables
class SomeTable(tables.ModelTable):
name = tables.Column(data="something__data__name")
rating = tables.Column(data="rating")
date = tables.Column(data="date_added")
class Meta:
pass
--------------------------------------------
Then here is a snippet from my view
--------------------------------------------
def some_view(request, user_id):
ratings = Rating.objects.filter(user__id=user_id)
table = RatingsTable(ratings, order_by=(request.GET.get(
"sort", "rating")))
--------------------------------------------
In my template i've assigned the table var in the view to a table var
in the template
Accessing the columns headers works fine
{% for column in table.columns %}
...
{% endfor %}
Looking at the README it looks like you can access the data directly
from the row:
for country in countries.rows:
print
country.city.id
print country.city.geo
print
country.city.founder.name
However, I have to prefix it with data so the above example would give
me an attribute error
here is what I would have to do
for country in countries.rows:
print
country.data.city.id
print country.data.city.geo
print
country.data.city.founder.name
Are you supposed to be able to access the data directly when fetching
each row, or do you need to use row.data.field? I wasn't sure if I
set mine up incorrectly since I didn't have all of the fields as
attributes, just data, table, and as_html.
Thank,s
Aaron