Switch branches/tags
Pull request Compare This branch is 13 commits ahead, 22 commits behind nvie:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



django-offsite-avatar makes it easy to add Facebook and Gravatar avatar support to your Django application through the addition of a template tag.


This code is a backwards-incompatible fork of The newer package provides more general avatar functionality (including Gravatar as a default backup) but introduces a lot of code for file upload and storage. This project intends to support only avatars hosted by someone else - Facebook, Gravatar, Twitter, etc.


To install it, use pip:

pip install django-offsite-avatar


To use it with a Django installation, first place 'avatar' in the INSTALLED_APPS tuple of your file like so:

    # ...

This conflicts with the django-avatar package, but they should never really be installed side-by-side.

Here is sample usage in a template:

{% load avatar %}
{% avatar request.user %}

In the previous example, a Facebook profile picture will be displayed if one is available, falling back to a Gravatar if the user has an e-mail address, or finally a default image if there is no Gravatar available.

This templatetag assumes that you are using a custom User profile, and the profile has a facebook_id field. If the identifier is stored elsewhere, you can add a property to the profile like so:

class UserProfile(models.Model):

    def facebook_id(self):
        # Do whatever you need to do to find the identifier for this user
        return <...>

If you only want the URL and not the full blown img-tag, you can use the following functions:

{% avatar_for_user 'jtauber' %}

There are a few configuration variables available that you can use in your Django's

  • GRAVATAR_URL_PREFIX: The gravatar URL to use. Default:
  • FACEBOOK_AVATAR_URL_PREFIX: The Facebook profile picture URL to use. Default:
  • AVATAR_DEFAULT_IMAGE: The default image to use, see
  • AVATAR_IMG_CLASS: The default CSS class name to add to generated <img>-tags.