@cache_result()
@register.simple_tag
def primary_avatar(user, size=settings.AVATAR_DEFAULT_SIZE):
 alt = six.text_type(user)
 url = reverse('avatar_render_primary', kwargs={'user': user, 'size': size})
 return ('<img src="%s" alt="%s" width="%s" height="%s" />' % (url, alt, size, size))

@ cache_result ( ) @ register . simple_tag def primary_avatar ( user , size = settings . AVATAR_DEFAULT_SIZE ) : alt = six . text_type ( user ) url = reverse ( 'avatar_render_primary' , kwargs = { 'user' : user , 'size' : size } ) return ( '<img src="%s" alt="%s" width="%s" height="%s" />' % ( url , alt , size , size ) )
this tag tries to get the default avatar for a user without doing any db requests .