I think you can use some basic template language within a script block like below. myData is a stringified json object, that worked for me.
antje
<script> {% if myData %} var table_data = {{ myData|safe }}; {% else %} var table_data = null; {% endif %} </script> On Fri, Apr 3, 2020 at 4:00 PM Yacin Omar <yacinomar999@gmail.com> wrote:
--As I know, there is no way to use Django template language inside Javascript block so I searched for a way how to do it, I found a Django app on github called django-jsrender but unfortunately, there isn't enough documentation for this app and when I tried to use it I couldn't and this is my code:
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a1c20606-bf66-4638-a006-be592a938c66%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAN6tUh%3DQ4Ueh%2B%2BHA-2PwmYpv0MwLhc%3DFKMiDt9jz1GeKgiKiWA%40mail.gmail.com.
No comments:
Post a Comment