Hello all,
as it's my first post, if any django developer around, nice work! I appreciate the package, I've been able to pull a small project I had in mind for long, very easily with this.
I am needing help with one part of the Views.
I'm using a generic.ListView, nothing fancy, but then, as the list can get really big, I am trying to create a search box for it. I've read around of using get method, which is fine for me, but when I get into the view, and I override get_queryset I never find the kwargs dictionary to work the search.
I also tried overriding get method but I didn't find the args either.
I found a code on stackoverflow which seems to be what I am looking for, but it always return all(), even when django-debug-toolbar tells me the request was made with get data, the View doesn't show up any kwargs
Do anyone has a suggestion? related to both why I am not getting the kwargs and what's the best way to implement a search box on a ListView?
consider I am new to this
Thanks!
regards
---- code ---
def get_queryset(self):
try:
name = self.kwargs['name']
except:
name = ''
if (name != ''):
object_list = self.model.objects.filter(name__icontains = name)
else:
object_list = self.model.objects.all()
return object_list
---debug ---
View function Arguments Keyword arguments URL name
mymodel.views.MyModelListView () {} index