Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django GET ?q="parameter" in get_queryset Class Based View

How do I access the "parameter" word in the url:

operations_product_search/?q=parameter

here:

class ASearchView(ListView):

...

def get_queryset(self, **kwargs):
    q = self.kwargs["q"]  <--- This is not working
like image 268
Alejandro Veintimilla Avatar asked Dec 05 '22 16:12

Alejandro Veintimilla


2 Answers

It should be self.request.GET['q'].

like image 197
Daniel Roseman Avatar answered Dec 28 '22 07:12

Daniel Roseman


I get query parameters using query_params

def get_queryset(self):
    q = self.request.query_params.get('q', None)
like image 24
Ajeet Lakhani Avatar answered Dec 28 '22 07:12

Ajeet Lakhani