Prefill checkboxes and store in django


I have a multiselect drowdown. I want to display the selected values from a drop-down in a separate div as rows with multiple checkboxes to select. I have tried this code in JSFiddle, . Please let me know if there is any better approach. I need to pass this data(Selected dropdown value with selected checkbox for that row) to backend. Also, the next step would be if Mustard is selected then I need to prefill A,B and C checkboxes already and option to check the rest of the boxes(Will get the list of list of checkboxes to prefill from backend). How to have prefilled checkboxes? I’m thinking to have a many 2 many relationship for each drop-down with options of the checkboxes? Is it correct? Next time the drop-down should prechecked the checkbox that is already selected.