1
view.py過濾動態DJANGO
def total_rent(request):
context = RequestContext(request)
venues = Venue.objects.all()
places = Venue.objects.values_list('place', flat=True).distinct()
context1 = ({'venues': venues, 'places': places})
total = request.GET.get('venue')
context1.update({'total': total})
return render_to_response("test3.html", context1, context)
test3.html
<form action="" method="get">
<select name="pl">
<option selected="selected" disabled>---------</option>
{% for place in places %}
<option value="{{ place }}">{{ place }}</option>
{% endfor%}
</select>
<input type="button" value="filter" />
{% for venue in venues %}
<input type="radio" name="venue" id="venue{{ forloop.counter }}" value="{{ venue.rent }}">
<label for="venue{{ forloop.counter }}"></label>
{{venue.venue_Name}}
{{ venue.place }}parking:{{ venue.parking_area }}
Rs {{ venue.rent }}
{% endfor %}
<input type="submit" value="service" />
</form>
我想,當我選擇在droup向下menue和按鈕的地方pressent過濾場地被按下過濾內容
這裏有很多遺漏。您需要編寫一些javascript,以便在選擇場所時通過ajax獲取場地,然後更新場館選項,或者在選擇場所時重新發布表單,然後用正確的場地重新加載頁面,或者完成所有操作在javascript中過濾。給一個選項一個鏡頭,然後我們可以幫助你解決任何錯誤。 – jproffitt
你可以給一些基本的代碼開始 – petes93