Answer the question
In order to leave comments, you need to log in
How to dynamically add new select menus after selecting the previous one?
Django has a database with track names.
Based on this base, you need to create a playlist through the select menu, the number of tracks can be very different, so after selecting a track, you need to automatically show a new similar menu.
How to do it better?
Answer the question
In order to leave comments, you need to log in
The task is not fully described, but based on what I have, I can assume that there is a playlist model and tracks cling to it through many to many, in which case I would apply formsets. But if you need it to be asynchronous, then just send ajax on the server when saving the track, save the model, and generate the form in the template. Read about formsets in the docs where it is well described.
If you need to load something in the selects additionally, then use jquery, let's say there are categories in the form, choosing categories, load tracks, the easiest way is jquery, hang an event on the select
$("select").change(function(){
})
1. Django has no base. It is in MySQL there is a base. And in the database there is a table with the names of the tracks. Django pings the database and pushes the result into a dictionary.
2. Dynamic element loading is usually implemented either manually via Jquery + Ajax, or by data binding Angular + its http service.
Googled it myself on the 2nd point, I'm too lazy to paint everything in detail.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question