'use js variable in Django
userlist.html
<a id="{{user.id}}" href="/followerPosting?id={{following.id}}" class="btn">profile</a>
I want to pass the id value to the url when the btn is clicked.
followerPosting.html
<script type="text/javascript">
var url = require('url');
var queryData = url.parse(request.url, true).query;
var fid = queryData.id;
</script>
So I parsed the URL and stored the id value in a variable (fid).
{% for twit in twits %}
{% if twit.User.id == fid %}
<div class="twit">
<div class="twit-content">{{twit.content}}</div>
</div>
{% endif %}
{% endfor %}
I want to use this variable in html (django) how can I use this value?
I tried to use Ejs but it didn't work well...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
