Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!