Im doing server side rendering with the help of Django. In my django templates Im looping through all the values obtained from my Database. In jquery while selecting a single value, JS gives me all the values obtained from database, but I wanted only selected values
Views.py
def theme(request):
context={}
context['All']=Theme.objects.all().count()
for t in ThemeCategory.objects.all():
context[t.categoryName]= t.theme_set.count()
context=collections.OrderedDict(sorted(context.items()))
return render(request,'theme-list.html',{'category_name':context})
In templates
<ul class="pick-tags" >
{% for category_name,count in category_name.items %}
<li id="item_cat">
<span id="item_cat_name">{{ category_name }}</span>
</li>
{% endfor %}
</ul>
In jquery Im selecting the required value
$('li#item_cat').on('click', function () {
alert($('span#item_cat_name').text())
})
But instead of giving me a single value, It me all the value obtained from DB.
How should I get only one value when click on <li>
Any help in obtaining selected value would be helpful