I\'m trying to get data by id in my django app. The problem is that I don\'t know the kind of id the user will click on. I input the below codes in views.
Views
looks to me that your urlconf is to blame, it should be:
url(r'^cribme/(?P\d+)/$', 'meebapp.views.cribdetail', name='cribdetail'),
not:
url(r'^cribme/(?P)\d+/$', 'meebapp.views.cribdetail', name='cribdetail'),
?P
means "give the matched string between parentheses this name. () matches nothing, which is why your app give an error when trying to look up the item with id ''
.
When the parentheses enclose the \d+
, you match a natural number, which should work.