Closed dragon-fire-fly closed 1 year ago
Found this stack overflow article which addresses this problem: https://stackoverflow.com/questions/33597775/django-checkboxselectmultiple-my-checkboxes-are-not-checked
Added the following code to each of the relevant form classes:
def __init__(self, *args, **kwargs):
super(UserEditForm, self).__init__(*args, **kwargs)
p_lang_q_set = ProgrammingLanguage.objects.filter(user=self.instance)
p_langs_init = []
for lang in p_lang_q_set:
p_langs_init.append(lang.pk)
self.initial["p_language"] = p_langs_init
Describe the bug When a user goes to the edit form for either the user or a project, the programming language checkboxes are not pre-checked with the information in the database. Even if programming languages are associated with a user/project, the checkboxes are all rendered unchecked.
To Reproduce Steps to reproduce the behavior:
Expected behavior If the user/project has associated programming language(s), the checkbox(es) for that language(s) should render pre-checked.
Screenshots prior to entering the update form: in the update form:
Desktop (please complete the following information):
Additional context When checkboxes are checked in the edit profile/project form, the data is being saved to the programming language database, so connection between the checkboxes and the database does not appear to be the issue.