-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No longer able to manually reference column values when iterating through rows in a template #485
No longer able to manually reference column values when iterating through rows in a template #485
Comments
This is how the supplied template iterates over the rows and columns: So I'd say something like this should work: {% for row in table.rows %}
{% for column, cell in row.items %}
{{ column.header }}
{% endfor %}
{% endfor %} |
Hi - many thanks for your response. My problem is that I just want to refer a subset of values from a subset of cells. E.g. how do I just print out the values of "det_id", "x" and "y"? |
I know how to do that in Python, but I need the template syntax. Are you saying that I need to refer to (e.g.) row.record.det_id, row.record.x, row.record.y? This is fine, but it also means that I have to follow the foreign keys from the underlying record. (So why bother with tables at all?) Surely part of the point of creating a table with fields that join more than one underlying model is that I shouldn't need to reference them explicitly via the foreign keys. In django_tables2 1.1.1 I can reference each column of my table. In this case I need the equivalent of whetever calls the get_cell method. |
I see, I was not thinking your use case through. You are the second one to report that you need to access the keys in templates, so apparently, django-tables2 is useful without having that. The reason we removed the magic which allows Orignal bug: #316 |
@genghisken would |
Yes - that would be great! |
After some delay, it's in there: released 1.19.0
|
Hi
I came to django_tables2 via django_tables.
There are a few occasions when I want to manually iterate through the columns of each row of a table in my template. I've always done this using (e.g. for the det_id column):
It's worked OK in my code for years - on Django 1.9 and django_tables2 1.1.1
However, I recently upgraded to django_tables2 1.10, and this no longer works. (The variable does not exist, but it iterates through the right number of rows.) Can you direct me to the preferred mechanism if I want to manually refer to one of my fields in a template.
The text was updated successfully, but these errors were encountered: