cpoudevigne cpoudevigne - 3 months ago 16
Python Question

Django avatar class not work

In django-avatar I want to add a custom CSS class using the template tag, but it's not working.

My template:

{% load avatar_tags %}

<li>
<span class="userhome">
{% avatar user 50 class="mmb-img" id="user_avatar" %}
Welcome : {{ user.username }}
</span>
</li>


The rendered HTML is:

<li>
<span class="userhome">
<img src="https://www.gravatar.com/avatar/4bbcb352e5bdbe63fe8f9a5786ea9d69/?s=50" alt="cpoudevigne" width="50" height="50">
Welcome : cpoudevigne
</span>
</li>


The custom class does not appear. What is the problem?

Answer

Same issue here, unable to set neither class="" nor id="".

No idea what's going on, so temporarily I can only set it via JavaScript/JQuery.

JQuery:

$(function() {$("span.userhome img").addClass("img-responsive")});
Comments