Source

django-gravatar /

Filename Size Date modified Message
django_gravatar
example
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).

Example

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/manage.py runserver --pythonpath='.' \
  --settings='example.settings'

Then browse to:

http://localhost:8000/email/<some@email.address>

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

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

TODO

Links

Visit the main Mercurial repository at bitbucket.

Visit the mirror Git repository at github.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.