문제

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:)

도움이 되었습니까?

해결책

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()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top