On Tuesday, February 8, 2011 7:18:59 PM UTC, gintare wrote: > > > *.html > > <form action="/MainForm" method="POST"> > {% csrf_token %} > <input type="submit" value="StartSearch" name="Search"> > > <small><small><TD>starts</TD><TD><input type="radio" name="rLkIn" > value="rstartsLkIn"</TD> > <TD>ends</TD><TD><input type="radio" name="rLkIn" value="rendsLkIn"</ > TD> > <TD>contains</TD><TD><input type="radio" name="rLkIn" > value="rcontainsLkIn" checked</TD> > <TD>equal</small></TD><TD><input type="radio" name="rLkIn" > value="requalLkIn"</TD></small></small> > > <form> > ''''''''''''''''''''''''############################################# > views.py > > rstartsLkIn, rendsLkIn, rcontainsLkIn, requalLkIn = > request.POST.get('rstartsLkIn','') , > request.POST.get('rendsLkIn','') , > request.POST.get('rcontainsLkIn','') , > request.POST.get('requalLkIn','') > > if (rcontainsLkIn)... gives none although it is already preselected > initially. > > How i should read value from radio buttons? > Check-boxes works perfectly. > > regards, > gintare >
You're testing for the keys, instead of the values. You have a single radio button, whose name is "rLkIn" (any reason you can't use readable names?). So that's the key in request.POST. The value will be the selected button: if request.POST.get('rLKln') == 'rcontainsLkln' However, you really really should learn Django forms, which does all this for you. -- DR. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.