Template:
<form method="POST" action="/Bycategory/">
<input type="radio" name="andor1" value=1 checked>
<input type="radio" name="andor1" value=2>
<select id="pathology_id" name="pathology_id">
{% for pathology in pathology_list %}
<option value="{{ pathology.id }}">{{ pathology.pathology }}</option>
{% endfor %}
</select>
There are actually three search selects(pathology, commodity, technology) The user can do and/or for a mix or match of the three, which is why I need the and/or option in the views.py.
The views.py:
def Bypub(request):
andor1 = request.POST['andor1']
pathology_id = request.POST['pathology_id']
p = get_object_or_404(Pathology, pk=pathology_id)
pub1=Publication.objects.exclude(pathpubcombo__pathology__id= 1).filter(pathpubcombo__pathology=p)
list=[]
andlist=[]
for publication in pub1:
if andor1 == 1:
if publication not in list:
list.append(publication)
if andor1 == 2:
if publication in list:
andlist.append(publication)
#list=andlist
return render_to_response('search/categories.html', {
'andor1' : andor1,
'pub1': pub1,
'pathology': p,
'list' : list,
'andlist' : andlist,
},
context_instance=RequestContext(request)
)
I know that all my code works without error, but the line (if andor1 ==1:) and (if andor1 ==2:) is being ignored. I suspect that the value for andor1 does not appear at the point where I'm using it. I think it doesn't actually render until after the return render_to_response, because it appears in the next template as a value, otherwise I would see some kind of response at the if andor1 ==1: in the template. Any suggestions?