T
T
Tobim2021-02-23 17:09:02
JavaScript
Tobim, 2021-02-23 17:09:02

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

2 answer(s)
D
Dmitry, 2021-02-24
@Tobim

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.

A
Anton Belokurov, 2021-02-24
@kyern

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 question

Ask a Question

731 491 924 answers to any question