Link to django-tables2

I use django-tables2 to show some data on the page, and now I want to make a cell link to some URL, but the URL of the link, for example:

url (r '^ (? P \ w +) / (? P \ d +) / $', 'pool.views.pooldatestock', name = "pool_date_stock"),

and I read the django-tables2 docs, but I can't find any example of this problem.

tables are displayed in the URL of the page in the same way as: http://127.0.0.1: 8000 / pool / 20111222 /

I am trying to write this in my .py tables:

class PoolTable(tables.Table): number = tables.LinkColumn('pool.views.pooldatestock', args=[A('number')]) date = tables.Column() 

and then I try to write:

 class PoolTable(tables.Table): number=tables.LinkColumn('pool.views.pooldatestock', args=[A('date')], kwargs=A('number')]) date = tables.Column() 

but a mistake too ...

can someone tell me how to solve this problem, or I need to create my own table view without django tables.

Thanks and Merry Christmas :)

+6
source share
1 answer

There is no point in assigning a list for the kwargs parameter, it should be given a dict . However, since your URL does not use named groups, it does not need keyword arguments anyway. Just put both URL parameters in args parameter:

 class PoolTable(tables.Table): number = tables.LinkColumn('pool.views.pooldatestock', args=[A('date'), A('number')]) date = tables.Column() 
+5
source

Source: https://habr.com/ru/post/904372/


All Articles