Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
Django change ListView query based on selected option from dropdown menu without reloading page

I want to create a ListView that displays items from the Inventory model based on the selected Site from the dropdown menu without reloading the page as shown here: enter image description here

I tried passing in site.pk into the ListView filter which comes from the HTML template, but I believe this would reload the page and would pass it into the url (we prefer it not to).

inventory.html

{% for site in data.project_sites %}
      <a href="{% url 'inventory:list-inventory' site.pk %}">
        <option value="{{site.pk}}">{{ site.siteName }}</option>
      </a>
      {% endfor %}

views.py

class InventoryListView(LoginRequiredMixin, generic.ListView):
    ...
    model = Inventory
    def get_queryset(self):
        qs = { 
            "inventory": Inventory.objects.filter(id=self.request.GET.get('site.pk')),
            "project_sites": Site.objects.all(),
            }
        return qs

I understand that this requires Javascript, but my group does not have much experience with Javascript and we have a short timeline for this.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda