In a django template i have this js script:
const formData = new FormData(form);
formData.append('taglist', JSON.stringify(selectedTagIds));
console.log(JSON.parse(formData.get('taglist')))
console.log(formData.get('title_raw'))
form.submit()
selectedTagIds
is an array. The console logs it correctly. After submitting I can access every standard form field in the django view but not the "taglist
". The field doesn’t exist in the form. When I try to print it i get "None
". What am I doing wrong?
2
Answers
If it isn’t a member in your form class, you can access it by calling
One easy way would be to add the stringified array in the value of a hidden input in the form to submit.