Sunday, January 3, 2016

Re: hello. get_queryset question

Hello All,

Greetings of New Year !!

I wanted to ask that i have just started web development and i wanted to learn django in deep by making a full dynamic website.

What Should Be the path which i should follow i.e. what are the prerequisites which i have to fulfill to become a full stack Django developer.
and any tips will be apprecieted.

On Mon, Jan 4, 2016 at 7:58 AM, Vijay Khemlani <vkhemlan@gmail.com> wrote:
Try with

self.request.GET['name']

On Sun, Jan 3, 2016 at 11:22 PM, Víctor Suárez <vesr.caracas@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+unsubscribe@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.
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+unsubscribe@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.



--
Regards,

Jai Goyal
Computer Science, Sophomore
Active Member,Cybros,The LNMIIT,Jaipur

" Don't worry about failure, you only have to be right once - Drew Houston "

--
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+unsubscribe@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/CAHxgRhvOUkMJzgxwOjpEFq2REpE%3DscxWgbxuDncsc4JsiDMCPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment