Ghasem
Ghasem

Reputation: 15603

Using AngularJS template tag inside Django {% %} tag

I've changed my AngularJS template tags to {$ $} and I have this code in my Django powered webpage:

<li data-ng-repeat="image in pictures[currentCat]">
    <a>
        <img src="{% static '{$ image.imgs $}' %}" />
    </a>
</li>

Now as this answer in my other question, I tried this solution:

<img src="{% static image.imgs %}" />

But then image.imgs is not a django variable so there's no picture.

I also tried this workaround:

<img src="src="static/{$ image.imgs $}" />

It works but only if DEBUG=TRUE. When I changed it to False, problem is still there. How can I solve it?

UPDATE

The html rendered code for image src is:

src="/static/%7B%24%20image.imgs%20%24%7D"

Upvotes: 0

Views: 659

Answers (1)

Ghasem
Ghasem

Reputation: 15603

I did this trick as a workaround and it works perfect no matter whether DEBUG=True or False:

<img src="{% static a %}{$ image.imgs $}" />

Upvotes: 1

Related Questions