Search code examples
sqldjangodjango-select-related

django-avatar, 1 query per avatar loaded


I'm displaying a page with around 60 avatars using django-avatar and a query is made for each one of them.

I cannot use User.objects.select_related('avatar') because there is no link between my user and his avatar. So how do I optimize this?

EDIT:

Avatars are retrieved in the template using {% avatar user %} (this is a template tag specific to github.com/jezdez/django-avatar, which seems to be the most used application for handling user avatars. I'm asking this question because some people certainly already had to face the issue of displaying many avatars using this application and I would like to know their solution).


Solution

  • Using the cache (like memcached) is the answer.