cpoudevigne
cpoudevigne

Reputation: 7

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?

Upvotes: 0

Views: 147

Answers (2)

Valorad
Valorad

Reputation: 736

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")});

Upvotes: 0

solarissmoke
solarissmoke

Reputation: 31494

This is probably because the app caches the output of those template tags:

AVATAR_CACHE_ENABLED

Set to False if you completely disable avatar caching. Defaults to True.

Either change the AVATAR_CACHE_ENABLED setting or clear your cache.

Upvotes: 2

Related Questions