Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango Tables adding a LinkColumn / NoReverseMatch Error
    text
    copied!<p>I have a model with some fields and I want to add a LinkColumn to a detail page. I have a working version, but I want to move to django-tables2</p> <p>The problem is that the link column doesnt show any link, just a "-"</p> <p>The model </p> <pre><code>class Events(models.Model): id = models.IntegerField(primary_key=True) date = models.DateField(null=True, blank=True) time = models.TimeField(null=True, blank=True) </code></pre> <p>The Table. Here I tried with <code>args=[A('id')]</code> and <code>args=[A('pk')]</code></p> <pre><code>class EventsTable(tables.Table): time = tables.TemplateColumn("{{value|time:'H:i'}}", verbose_name='Time UTC') detail_link = tables.LinkColumn('detail', args=[A('id')], verbose_name='Detail') class Meta: model = Events attrs = {"class": "paleblue"} fields = ("date", "time", "detail_link") </code></pre> <p>mi url pattern is</p> <pre><code>urlpatterns = patterns('', url(r'^$', views.index, name='index'), url(r'^(?P&lt;event_id&gt;\d+)/$', views.detail, name='detail'), ) </code></pre> <p>and the view </p> <pre><code>def index(request): table = EventsTable(Events.objects.all(), order_by=('-date', '-time')) RequestConfig(request, paginate={"per_page": PAGE_LIMIT}).configure(table) return render(request, "db_interface/events.html", {"table": table}) </code></pre> <hr> <p>EDIT: Changing the detail_link to </p> <pre><code>detail_link = tables.LinkColumn('detail', args=[A('id')], verbose_name='Detail', empty_values=()) </code></pre> <p>now I got a NoReverseMatch Exception</p> <pre><code>Reverse for 'detail' with arguments '(5075,)' and keyword arguments '{}' not found </code></pre> <p>the number 5075 is the id of the first event. I dont know if for any reason is not passing the argument as an int ? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload