django-gravatar /

Filename Size Date modified Message
30 B
60 B
17 B
1.0 KB
2.4 KB

Django Gravatar

django-gravatar is a Django application that exports template tags to convert email addresses to Gravatar-stored avatars, as dynamically generated hyperlinks.

By including the app, django_gravatar, in your settings module, you can load a custom templatetags module, gravatar_tags, to generate a Gravatar URL from an input of an email address and a set of optional parameters.

To load the custom tags into your template, include the following:

{% load gravatar_tags %}

Currently, this will enable the following tags:

{% gravatar_url <email> <params> %}
{% gravatar_url <email> %}

Where <email> is either a string variable or a string literal of an email address, and <params> is either an object or dictionary variable of the following set of parameters:

  • size -- corresponding to Gravatar parameter s, the value must be between 1 and 512, inclusive. The default is 80.
  • rating -- corresponding to Gravatar parameter r, the value must be in ('g', 'pg', 'r', 'x'). The default is 'g'.
  • default -- corresponding to Gravatar parameter d, the value must be in ('identicon', 'monsterid', 'wavatar', '404') or a valid URI. The default is nothing.

For size and rating, when the given value is already default (i.e., 80 or 'g', respectively), it will be omitted in the generated URL parameters.

If no <params> argument is supplied, the defaults will be used (that is, omitted to rely on Gravatar's default fallback values).


Besides the django_gravatar directory, where the app logic is that you should include or point to in your project, this directory also includes a dummy project harness to demonstrate and/or test the app.

To demonstrate the example harness:

# from this directory
$ python example/ runserver --pythonpath='.' \

Then browse to:


To run unit tests (one is included with the django_gravatar app), use the harness:

# from this directory
$ python example/ test --pythonpath='.'



Visit the main Mercurial repository at bitbucket.

Visit the mirror Git repository at github.