I have a dynamic table containing a select list of items. While i click the add riw button, I’m trying to append a django for loop in javascript:
var fieldHTML = ’ {% for item in item_list %} {{item.item_name}} {% endfor %} Select Item ';
$(wrapper).append(fieldHTML);
But in the django template it is showing as
{{item.item_name}} in the dropdown select list.
Kindly help
Hi,
if I understand correctly that you want your JavaScript to trigger Django templating then that is not possible.
Django templates are rendered on the server and send to the browser. You cannot modify them once they are rendered.
1 Like
Thank you for the quick response.
Is there any way to dynamically append this row everytime a button is clicked
If you’re looking to dynamically add data to your page, where that data is Django-template-rendered, your JavaScript would need to make an AJAX call to a view that generates the appropriate HTML and returns it. The JavaScript then appends that fragment to your page.
1 Like