Skip to content
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

Can't get linkify to work #721

Closed
Nebucatnetzer opened this issue Dec 11, 2019 · 2 comments
Closed

Can't get linkify to work #721

Nebucatnetzer opened this issue Dec 11, 2019 · 2 comments

Comments

@Nebucatnetzer
Copy link

Nebucatnetzer commented Dec 11, 2019

I used the LinkColumn by mistake and now tried to change it to the normal column.
However I can't get it to work in one of the tables.
The cells just stay empy (---) in addition, I always get the following error when I try to sort the columns by clicking on the table header:

Cannot resolve keyword 'nets' into field. Choices are: adgroup, description, device, id, location, mailgroup, name, net, user

The code can be found here:
https://github.com/Nebucatnetzer/network_inventory/blob/net/network_inventory/inventory/tables.py
The only table which isn't work is the CustomersTable. I tried to apply the following code change:

-from django_tables2.utils import A
+
 
 class CustomersTable(tables.Table):
-    name = tables.LinkColumn('customer', args=[A('pk')])
-    nets = tables.LinkColumn('nets', text='Nets', args=[A('pk')])
-    computers = tables.LinkColumn('computers', text='Computers', args=[A('pk')])
-    devices = tables.LinkColumn('devices', text='Devices', args=[A('pk')])
-    backups = tables.LinkColumn('backups', text='Backups', args=[A('pk')])
+    name = tables.Column(linkify=("customer", [tables.A("pk")]))
+    nets = tables.Column(verbose_name="Nets",
+                         linkify=("nets", [tables.A("pk")]))
+    computers = tables.Column(verbose_name="Computers",
+                              linkify=("computers", [tables.A("pk")]))
+    devices = tables.Column(verbose_name="Devices",
+                            linkify=("devices", [tables.A("pk")]))
+    backups = tables.Column(verbose_name="Backups",
+                            linkify=dict(viewname="backups", args=[tables.A("pk")]))

This is with Python 3.8 and Django 2.2.8

@jieter
Copy link
Owner

jieter commented Dec 18, 2019

This is an issue tracker to report bugs and request features, not a place to ask for help on using the library. Please use stackoverflow and tag your question with django-tables2

That said: the text-argument is currently only supported by LinkColumn. You can work around this by adding a bunch of methods like def render_nets(self): return "Nets" methods and adding empty_values=() to each column, but that's not really clean.

Maybe the message in the docs is not the best idea until we implement implement something like the text argument` to the basic column.

@Nebucatnetzer
Copy link
Author

This is an issue tracker to report bugs and request features, not a place to ask for help on using the library. Please use stackoverflow and tag your question with django-tables2

Sure will do that next time.
Maybe you want to add this to the documentation or the readme?

That said: the text-argument is currently only supported by LinkColumn. You can work around this by adding a bunch of methods like def render_nets(self): return "Nets" methods and adding empty_values=() to each column, but that's not really clean.

Maybe the message in the docs is not the best idea until we implement implement something like the text argument` to the basic column.

Okay in that case I will leave the table as it is for the moment. It's only one table which works like this and I can easily convert it when it's required.

Thank you for the reply, its solved for me :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants