Skip to main content

Essential Gravatar support for Django. Features helper methods, templatetags and a full test suite!

Project description

django-gravatar

A lightweight django-gravatar app. Includes helper methods for interacting with gravatars outside of template code.

https://secure.travis-ci.org/twaddington/django-gravatar.png

Features

  • Helper methods for constructing a gravatar url and checking an email for an existing gravatar

  • Templatetags for generating a gravatar url or gravatar <img> tag.

  • Full test suite!

Installing

You can pip install the app directly from GitHub:

$ pip install git+git://github.com/twaddington/django-gravatar.git#egg=DjangoGravatar

Alternatively, you can now install directly from PyPi!

$ pip install django-gravatar2

Make sure you install django-gravatar2 as there are several other incompatible django-gravatar libraries available.

Add django_gravatar to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = (
    # ...
    'django_gravatar',
)

Basic Usage

Use in code:

from django_gravatar.helpers import get_gravatar_url, has_gravatar

url = get_gravatar_url('alice@example.com', size=150)
gravatar_exists = has_gravatar('bob@example.com')

Use in templates:

{% load gravatar %}

{% gravatar_url user.email 150 %}
# https://secure.gravatar.com/avatar/hash.jpg?size=150

{% gravatar user.email 150 %}
# <img class="gravatar" src="https://secure.gravatar.com/avatar/hash.jpg?size=150" width="150" height="150" alt="" />

{% gravatar user.email 150 "user@example.com" %}
# <img class="gravatar" src="https://secure.gravatar.com/avatar/hash.jpg?size=150" width="150" height="150" alt="user@example.com" />

Configuring

The following options can be configured in your settings.py:

GRAVATAR_URL # Gravatar base url. Defaults to ‘http://www.gravatar.com/

GRAVATAR_SECURE_URL # Gravatar base secure https url. Defaults to ‘https://secure.gravatar.com/

GRAVATAR_DEFAULT_SIZE # Gravatar size in pixels. Defaults to ‘80’

GRAVATAR_DEFAULT_IMAGE # An image url or one of the following: ‘mm’, ‘identicon’, ‘monsterid’, ‘wavatar’, ‘retro’. Defaults to ‘mm’

GRAVATAR_DEFAULT_RATING # One of the following: ‘g’, ‘pg’, ‘r’, ‘x’. Defaults to ‘g’

GRAVATAR_DEFAULT_SECURE # True to use https by default, False for plain http. Defaults to True

Contributing

Feel free to fork django-gravatar on GitHub! We’d love to see your pull requests. Please make sure you run tests before submitting a patch.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-gravatar2-1.0.6.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

django_gravatar2-1.0.6-py2.7.egg (12.0 kB view details)

Uploaded Egg

File details

Details for the file django-gravatar2-1.0.6.tar.gz.

File metadata

File hashes

Hashes for django-gravatar2-1.0.6.tar.gz
Algorithm Hash digest
SHA256 26008d11b3f7ce60adf3415b0a612d7e38a9975bebcba4956e7366d2a242ec70
MD5 176fef51a71c576fdfe769a3bb35cbbc
BLAKE2b-256 77dff5e9acb1ee4af51b1b067024305fb7b81bfdea9d62bb9b5aaab2dabc10f1

See more details on using hashes here.

File details

Details for the file django_gravatar2-1.0.6-py2.7.egg.

File metadata

File hashes

Hashes for django_gravatar2-1.0.6-py2.7.egg
Algorithm Hash digest
SHA256 d991b36666791c45aee735898a9eecf67286fb2463def45754bdec67e2890591
MD5 31b7402ab1d5167db057faedbf8adf8d
BLAKE2b-256 92189123c093b42f1f8a6b0cf53094e95de40b95f6dcb28a9c3893e9b805afc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page