I am trying to make my first column, which is the ID column clickable to go to a detailed view. I had it working with normal tables as:
{% for tickets in tickets %}
...
<td><a href="{{tickets.get_absolute_url}}">{{tickets.id}}</a> </td>
...
{% endfor %}
What I have now using django-tables2 is this:
class TicketsTable(tables.Table):
class Meta:
model = Tickets
fields = ("id", "subject", "desc", )
id = tables.LinkColumn('tickets.get_absolute_url', tickets.id)
Pretty sure this is way off. I am using a slug field named 'slug' for the different links. I am still pretty new to this so I am unsure how to proceed.
The code that worked was:
#tables.py
import django_tables2 as tables
from ticker.apps.ticket.models import Tickets
from django_tables2.utils import A
class TicketsTable(tables.Table):
id = tables.LinkColumn('ticket_detail', args={A("slug")})
subject =tables.Column()