Answer the question
In order to leave comments, you need to log in
How to change content in select depending on another in django?
I have two selects, one category, another product. The category is connected to the product in the models through the primary key. How to make it so that when a user selects a category in another select there are only those products that have the selected category?
Answer the question
In order to leave comments, you need to log in
Tobim implements this with jQuery and jquery.chained.js
How you implement this on the django side can have several options. Depends on how you render the template.
1. Fill in the select with products using AJAX after selecting a category.
2. After selecting a category, send a get request indicating the selected category and generate its content on the Django side.
3. Send everything from Django and filter with templates or javascript on the client, but I would not seriously consider this option.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question