Hello everyone.
I have a dynamic formulary that when a user types a query, it shows some radio box. And i get this error when i submit the form:
MultiValueDictKeyError at /add_company/ "Key 'radioramo' not found in < QueryDict:...
A sample of my javascript code:
var elem = document.getElementById('div_field');
var radio_ramo = document.createElement("input");
radio_ramo.type = "radio";
radio_ramo.name = "radioramo";
radio_ramo.id = "radioramo";
radio_ramo.value = $(aux).find(tag).text();
elem.appendChild(radio_ramo);
In my views.py I have this:
def add_company(request):
if request.POST:
cform = CompanyModelForm(request.POST)
ramo = request.POST['radioramo']
if cform.is_valid():
newCompany = cform.save(commit= False)
newCompany.ramo = ramo
newCompany.save()
cform.save_m2m()
Django didn't recognize the new tag "radioramo". Anyone knows how can I get the selected radio value?
I appreciate any help. Thank you!