Reputation: 389
I'm currently trying to add a Link column
into a table that I have created already using Django tables 2.
I'm using the following code from the documentation
class PeopleTable(tables.Table):
name = tables.LinkColumn('people_detail', text='static text', args=[A('pk')])
view.py
urlpatterns = patterns('',
url('people/(\d+)/', views.people_detail, name='people_detail')
)
The problem is, when i try to load my webpage i get the following error:
Reverse for 'people_detail' with arguments '(1,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Can anyone see the problem here?
EDIT: My url.py looks like the following:
urlpatterns = [
url(r'^$', views.IndexView, name='index'),
url(r'^Search/$', views.SearchView, name='Search'),
url(r'^people/(\d+)/$', views.myview,{}, name='people_detail'),
url(r'^comment/$', views.LicenseComment, name='comment'),
url(r'^copyLicense/$', views.copyLicense, name='Copy'),
url(r'^download/$', views.download, name='Download'),
url(r'^AddMod/$', views.addModule, name='addMod'),
url(r'^removeMod/$', views.removeModule, name='removeMod'),
url(r'^login/$', views.Login.as_view(), name='login'),
url(r'^logout/$', views.LogOut, name='logout'),
url(r'^create/$', views.get_name, name='create'),
url(r'^NewLicense/$', views.NewLicense.as_view(), name='NewLicense'),
url(r'^LicenseCharts/$', views.Chart.as_view(), name='ViewChart'),
url(r'^Advancedsearch/$', views.Adsearch.as_view(), name='AdSearch'),
url(r'^AdvancedRequest/$', views.AdvancedRequest, name='AdvancedRequest'),
url(r'^EditLicense/$', views.EditLicense.as_view(), name='EditLic'),
url(r'^Profile/$', views.profileView.as_view(), name='profile'),
url(r'^GlobalLog/$', views.LogFile.as_view(), name='LogFile'),
]
Also if i remove the text='static files'
from where i create the link column, this error no longer appears, but the table just contains a column called Name that contains only a dash
Upvotes: 2
Views: 7907
Reputation: 4882
Similar scenario
My app name - "ecart"
url.py (under ecart app)
path("ecart/edit/...", edit_ecart, name="edit_ecart")
tables.py (exists under same hierarchy i.e. ecart app)
from django_tables2.utils import A
import django_tables2 as tables
class CartTable(tables.Table):
edit_col = tables.LinkColumn('edit_ecart', text='EDIT', args=[A('pk')] )
----------
----------
This will show EDIT hyperlink column as last column in table
Note: I did not required to add namespace name, i.e "ecart:edit_ecart" as both the above files are in same hierarchy
Upvotes: 2
Reputation: 308869
If you included your urls.py with a namespace, then you have to include the namespace when defining the link column. For example:
class PeopleTable(tables.Table):
name = tables.LinkColumn('myapp:people_detail', text='static text', args=[A('pk')])
Upvotes: 6