You are welcome Happy that you solve your problem. *Adailton do Nascimento* *(11) 95493-7660* *Software Engineer*
[image: Linkedin] <https://htmlsig.com/t/0000001BTZ2FC> [image: github] <https://github.com/dhelbegor> Em ter., 9 de jun. de 2020 às 11:30, Agnese Camellini < agnese.camell...@gmail.com> escreveu: > Thanks a lot Adailton > . > I have figured out by myself di use wury_params but i've made the action > more static, for security reasons. > Thanks a lot however. > Agnese > > On Tue, 9 Jun 2020 at 16:26, Adailton Nascimento <dhelbeg...@gmail.com> > wrote: > >> Firstly if you wanna use your custom mixin instead of drf filter backends >> you will need to do the following. >> >> you are trying to query query param using kwargs it's wrong, instead use >> self.query_params. and your f is a dict() >> >> def get_queryset(self): >> f = dict() >> for field in self.lookup_fields: >> f.update({field: self.request.query_params.get(field)}) >> return # do what you want, remember, it's possible to receive more >> than one query param from query params, so get_object_or_404 won't work if >> you pass more than one param. >> >> >> PS: self.query_params return a dict, so you don't need to use lookup >> fields instead do ... >> def get_queryset(self): >> query_params = self.request.query_params >> return User.objects.filter(**query_params) >> >> >> PS2:I highly recommend to use drf filter backend. >> >> PS3: a personal tip try to use an idle that allows you to see the source >> code of the framework you are using. and try to adhere to the use of pdb >> debugging things it is much easier to identify what you want or just use >> print. tip: print('>>>>>', self.query_params). :D >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django REST framework" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-rest-framework+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-rest-framework/ca259028-5a0c-47fa-a324-f56b2f750495o%40googlegroups.com >> <https://groups.google.com/d/msgid/django-rest-framework/ca259028-5a0c-47fa-a324-f56b2f750495o%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-rest-framework+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-rest-framework/CACXuh-SRtu5r2mWuxieOsnH8Qe3W9d54NU%3DQWakCCcYsUCuaPQ%40mail.gmail.com > <https://groups.google.com/d/msgid/django-rest-framework/CACXuh-SRtu5r2mWuxieOsnH8Qe3W9d54NU%3DQWakCCcYsUCuaPQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CA%2B87neC_VDnFP9x3Wf1OW2jm0-wUmbEhZn4-U%3DuFFL07BWx-uA%40mail.gmail.com.