Blog Logo
  • Home
  • About

django-simplegravatar v0.2

by Drew Engelson — 10 Nov 2011

What?

A simpler Django template tag to add Gravatar support to your Django projects. This is based on my 2008 post entitled Implementing Gravatar in Django.

Installation

To install this app, simply:

  1. pip install django-simplegravatar

    or drop the 'simplegravatar' folder somewhere on your PYTHONPATH

  2. Add 'simplegravatar' to your projects INSTALLED_APPS list in

    settings.py

Configuration

There are a few optional settings that can be added to your Django settings file to affect the global behavior of simplegravatar.

SIMPLEGRAVATAR_SIZE (default: 80)

Pixel width and height of Gravatar (they are all square)

SIMPLEGRAVATAR_RATING (default: 'g')

g, pg, r, x

SIMPLEGRAVATAR_DEFAULT (default: '')
Default image if no Gravatar exists for email. Should be a full image URL to your custom image, or one of the Gravatar built-in defaults...
  • 404: do not load any image if none is associated with the email hash, instead return an HTTP 404 (File Not Found) response
  • mm: (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)
  • identicon: a geometric pattern based on an email hash
  • monsterid: a generated 'monster' with different colors, faces, etc
  • wavatar: generated faces with differing features and backgrounds
  • retro: awesome generated, 8-bit arcade-style pixelated faces
SIMPLEGRAVATAR_SECURE (default: False)

Use https?

For more information about these default options see:

http://en.gravatar.com/site/implement/images/

USAGE (this goes in your templates)

{% load simplegravatar %}
{% show_gravatar "[email protected]" %}

You may optionally pass a size into this template tag:

{% show_gravatar "[email protected]" 48 %}

If you require a secure image (instead of using SETTINGS):

{% show_gravatar_secure "[email protected]" %}

Enjoy!

0%
django-simplegravatar v0.2
words - read.
Drew Engelson
Author

Drew Engelson

https://tomatohater.com

I currently lead the Cloud Foundation Services team at Starbucks. We are building the Starbucks PaaS to allow digital platforms to be deployed globally with a focus on automation, scalability, performance, security, and developer experience.

Prior to Starbucks, I led Celerity's Technology Innovation and Architecture practice and founded Zoombit and served in technology leadership at Huge and PBS.

I seriously hate tomatoes.

Comments

comments powered by Disqus
All content copyright Tomatohater © 2017 • All rights reserved.