Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The linkcolumn about django-tables2

I use django-tables2 to show some data in page,and now I want to make the cell link to some url,but the link url such as :

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

and I read the documents of django-tables2,but I can't find some excample about this problem.

the tables show in the page's url just like:http://127.0.0.1:8000/pool/20111222/

I try to write this in my tables.py :

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 it's error too...

somebody can tell me how to solve this problem?or should I create my own table view, without django-tables.

Thanks.and Merry Christmas:)

like image 320
sword Avatar asked Dec 23 '11 07:12

sword


1 Answers

It makes no sense for the kwargs parameter to be given a list, it should be given a dict. However as your URL doesn't used named groups, it doesn't need keyword arguments anyway. Just put both URL parameters in the args parameter:

class PoolTable(tables.Table):
    number = tables.LinkColumn('pool.views.pooldatestock',
                               args=[A('date'), A('number')])
    date = tables.Column()
like image 89
bradley.ayers Avatar answered Oct 14 '22 22:10

bradley.ayers