Wednesday, November 2, 2011

Onchange attribute for mdelformset

How can i access the form in django views.

Suppose

Modelform

class QuestionForm(forms.ModelForm):

answer = forms.ChoiceField(choices=HAY_EVALUATION_CHOICES,
widget=forms.Select(attrs={'onchange': 'this.form.submit();'}))


In views.py

if 'form-0-answer' in request.POST:

answer = request.POST.get('answer','')

values.append(answer)

return render_to_response('success.html')

if 'evaluation' in request.POST:

return render_to_response('results.html')

Here 'evaluation' name of Submit button

Here the problem is the form is always redirecting to success.html
even i click submit button


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment