Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

django string interpolation struggles

$
0
0

Hi so I am having a problem trying to concatenate in django. I have created a new templatetag and im trying to get the string interpolation right and im struggling a bit.

{% button text="Reset" onclick="test('{{user.id}}')" colour="yellow" %}function test(user_id){    console.log('user id:', user_id)}

the console log just gives back user id: {{user.id}}

{% button text="Reset" onclick="test('"|add:user.id|stringformat:"s"|add:"')" colour="yellow" %}

I have also tried this way but it just gives me a syntax error.

any help on how to properly do this or even if its not possible any help would be great.

(still new to django)


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>