Quantcast
Viewing all articles
Browse latest Browse all 14040

django string interpolation struggles

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 14040

Trending Articles