Note that there are some explanatory texts on larger screens.

plurals
  1. POformset is valid but form has no attribute cleaned_data!
    text
    copied!<p>Ok, so I have a formset that is valid. But gives me a error that that form has no attribute cleaned_data..</p> <p>Honestly I have absolutely no clue what's happening..<br> I tried my code on terminal and it returned a empty dictionary.. without errors..</p> <p>forms:</p> <pre><code>class Clinical(forms.Form): _names = list(ClinicalForm.objects.values_list('form_id', 'form_name')) _names.append(("New", u'Nova entrada')) cliform_name = forms.ChoiceField(widget=RadioSelect(), choices=_names, label ="", required=True) </code></pre> <p>views:</p> <pre><code>ClinicalSet = formset_factory(Clinical, extra=2) formset2 = ClinicalSet(request.POST) if formset2.is_valid(): choice1 = formset2.cleaned_data return render_to_response('valid_test.html', { 'formset2': formset2, 'wrongs1': wrongs1, 'choice1': choice1 }) else: formset2 = ClinicalSet() return render_to_response('valid_test.html', { 'formset2': formset2, 'wrongs1': wrongs1, }) </code></pre> <p>template:</p> <pre><code>&lt;form method="post" action=""&gt; &lt;div&gt; {{ formset2.management_form }} {% for form in formset2.forms %} {{ form }} {% endfor %} &lt;input type="submit" value="save" /&gt; &lt;/div&gt; </code></pre> <p> </p> <p>If I comment the line where the cleaned_data is called (choice1), I don't receive any error and I'm able to see the forms..<br> If I select some options and uncomment this line, it works.. </p> <p>I have a similar formset : <a href="https://stackoverflow.com/questions/5966993/both-forms-in-formset-need-to-be-selected">both forms in formset need to be selected</a> and this one works..</p> <p>the form that works is the first formset (linked above). The post parameters:</p> <pre><code>form-0-pres_name 1 form-1-pres_name 2 form-INITIAL_FORMS 0 form-TOTAL_FORMS 2 </code></pre> <p>the user select one option in each form and he's redirect to another view (this one - formset2).</p> <p>Any help is more than welcome..</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload