Skip to main content

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

Project description

https://travis-ci.org/twaddington/django-gravatar.svg?branch=master

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

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

Install from PyPi:

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, get_gravatar_profile_url, calculate_gravatar_hash

url = get_gravatar_url('alice@example.com', size=150)
gravatar_exists = has_gravatar('bob@example.com')
profile_url = get_gravatar_profile_url('alice@example.com')
email_hash = calculate_gravatar_hash('alice@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" />

{% gravatar_profile_url user.email %}
# https://secure.gravatar.com/hash

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.

Run tests:

$> cd example_projects
$> ./manage.py test django_gravatar

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.4.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

django_gravatar2-1.4.3-py2.py3-none-any.whl (10.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: django-gravatar2-1.4.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

File hashes

Hashes for django-gravatar2-1.4.3.tar.gz
Algorithm Hash digest
SHA256 20c5ce4926dd380bf17a0e97a8c781de0be867f08290026da7b7332e48ae9b85
MD5 98c573f7e554fbdd0f2c923b0ad20654
BLAKE2b-256 b68b11da6365c1c4630d1052698b038048459eec2c472e40586460d8d4189095

See more details on using hashes here.

File details

Details for the file django_gravatar2-1.4.3-py2.py3-none-any.whl.

File metadata

  • Download URL: django_gravatar2-1.4.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

File hashes

Hashes for django_gravatar2-1.4.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 93f5975d3bda4e7eedeed77481901f19b97c8cc5f467dbeae2a6d9a19386d6c4
MD5 1808d5f4a0f20df27cf327373a8af6e0
BLAKE2b-256 f591157551d6ceade5f13dfabe300a529ece225f2d32ad4c35a1364e2ef23557

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