Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda