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
Show related columns problem #256
Comments
Hi MikeSmith12222, You could use a render_FOO method to do something like that, to for example render the primary keys of the # tables.py
class ContactTable(tables.Table):
phone = tables.Column(empty_values=(),
verbose_name='Phone')
def render_phone(self, record):
# phone is the name of the related manager
if record.phone.exists():
return str([p.pk for p in record.phone.all()])
class Meta:
model = Contact Nonetheless, I'd advise against giving |
@hdmaker: Thank you so much for your quick response. This one really works.... Before I had tried to call a render function via an accessor which did not work. Your code snippet does the trick!!! Thanks a lot and for all you other django newbie geeks - this is the reference in the tutorial http://django-tables2.readthedocs.org/en/latest/pages/custom-rendering.html. P.S. |
I think I'll leave this issue open, as the accessor version in my original code is supposed to be working? |
@MikeSmith12222 Glad I could help you. You can let that issue open or not as your convenience, that bug is already referenced in #211 and #229. |
#211 has a solution, I'll look into that later. |
Hi guys,
damn.. I have spent around 4 hours on this problem.
I am using Django 1.8 with the latest django-tables2
and want to show some related data via the accessor option.
The problem:
The rendered table does output the verbose table-header for "phone",
BUT renders empty data for the column ("--").
Can you please give me a hint? I really need to get this to work asap.
Thanks a lot for your help!
This is my code that does NOT work:
The text was updated successfully, but these errors were encountered: