I need to loop through my django list that I have passed to the template.
I have this code in my django view:
if plan: investments = Investment.objects.all().filter(plan = plan).order_by('maturity_date').filter(maturity_date__gte = now) for i in investments: financial_institution = i.financial_institution amount = i.get_current_value(date) fi_list.append({ 'fi': financial_institution, 'amt':amount }) context['list'] = fi_list Which outputs:
[<financial_institution: Example> <amount: 5000>] Now what I want to do is loop through this list, and if my javascript variable matches the item in the list, do further code. However I am stuck on how to do this.
Here is my javascript so far, using jQuery:
function cdic_limit(amount) { var limit = 100000.00; var list ="{{ list }}"; var fi = $("#id_financial_institution option:selected").text(); } Down the road, what I ultimately want, is if the selected institution is in the list, check and make sure their total amount isn't exceeding $100k
Any suggestions?