I'm trying to send a parameter by URL and trying to use it in a listview. But I cant GET it in my view. I know I'm doing some stupid mistake, but can't find it.
This is the link I'm using in my template:
<a class="dropdown-item" href="{% url 'listarmateriales' tipolista='metales' %}">Ver metales
This is my url.py:
path('listarmateriales/<tipolista>',listarmateriales.as_view(), name='listarmateriales'),
And this is where I try to get the "tipolista" in my views.py:
class listarmateriales(ListView):
template_name = 'materiales/materialeslist.html'
def get_queryset(self):
if self.request.GET.get('tipolista') is not None:
lista=Materiales.objects.all()
tipolista=self.request.GET.get('tipolista' '')
if tipolista=='metales':
Do whatever...
else:
I have tried some different sintaxis, but the result is always the same, I cant read "tipolista", I have spent a lot of time with this, too much. I know it must be something easy, but, I'm new at this. Thanks in advance