Try with

self.request.GET['name']

On Sun, Jan 3, 2016 at 11:22 PM, Víctor Suárez <vesr.cara...@gmail.com>
wrote:

> 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
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2ffc172e-8ae7-4465-a4e3-f8352c067183%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2ffc172e-8ae7-4465-a4e3-f8352c067183%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei0YSC-2Yx2zMBCcQ--gen%3DPDtC%2B1cLnYrsN3fp46C8-ww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to