I have a page set up to load the results of a Django db query into a drop down list. Upon selection of an item, a table is generated with the relavant data.
Given the view method
def index(request):
parentorg_list = Parentorgs.objects.all()
context = {'parentorg_list' : parentorg_list}
return render(request, "app/index.html", context)
and
{% for org in parentorg_list %}
localStorage.setItem("{{org.parentorg}}", "{{org.parentorgName}}");
{% endfor %}
is there a way to add the items to the localstorage without Django generating ~500 lines of repeated localStorage.setItem()
? Or would I be better off in converting the index return to a JSON list for parsing?