I would like to pass a number to my generic view (DetailView) to get one object Here is my code
Urlpattern
(r'^newreportview/(?P<number>\w+)/$', NewReportView.as_view()),
View Class
class NewReportView(DetailView):
template_name = "report/newreportview.html"
context_object_name = "newreportview"
def get_queryset(self):
task= get_object_or_404(MyTask,applicationnnumber=self.args[0])
return task
I guess something is wrong in this line
name = get_object_or_404(MyTask,applicationnnumber=self.args[0])
error message:
Exception Type: IndexError
Exception Value:
tuple index out of range
How should I pass 'number' to this generic view and get a Mytask object with this 'number'?
Thanks