" /> " /> "/>

Is there a way to load avatar of each user using static method in Django?

67 Views Asked by At

I'm looping through each message which has a particular user which in intern as an image associated with it.

<img src="{{message.user.avatar.url}}" />

I want to convert it something like this (which I know is obviously very wrong)

<img src="{% static {{message.user.avatar.url}} %}" />

Is there a way to do so where I can find the equivalent working command of the above code?

1

There are 1 best solutions below

0
ShiBil PK On BEST ANSWER

Try using with

{% with avatar_url=message.user.avatar.url %}
<img src="{% static avatar_url %}" />
{% endwith %}