1👍
According to the w3 organization, if a <script>
tag has a src="…"
attribute, the content of the script is ignored, so it will never evaluate var user= …
. You should work with two tags:
<script src="{% static 'js/cart.js' %}"/> <script> var user = '{{request.user}}'; </script>
if js/cart.js
needs to user the user
variable, you need to define that first, so:
<script> var user = '{{request.user}}'; </script> <script src="{% static 'js/cart.js' %}"/>
0👍
I would recommend to add a breakpoint in your browser debugger in the line
var user=...
and reload the page.
Thus you can see if the line is executed before the card.js script.
- [Answered ]-Django get Foreignkey Reverse Model Queryset
- [Answered ]-Django get id of the selected checkbox on CheckboxSelectMultiple widget in Javascript
- [Answered ]-How to retain an added column in django queryset during serialization?
Source:stackexchange.com