Django Image Requests

← Back

Original submission from, and big thanks to . Modified and improved by Carly Stambaugh.

import hashlib
import urllib
from django import template
from django.utils.safestring import mark_safe

register = template.Library()

# return only the URL of the gravatar
# TEMPLATE USE:  {{ email|gravatar_url:150 }}
def gravatar_url(email, size=40):
  default = ""
  return "" % (hashlib.md5(email.lower()).hexdigest(), urllib.urlencode({'d':default, 's':str(size)}))

# return an image tag with the gravatar
# TEMPLATE USE:  {{ email|gravatar:150 }}
def gravatar(email, size=40):
    url = gravatar_url(email, size)
    return mark_safe('' % (url, size, size))

See Also: and if you use Python 3 try out . Both are third party libraries and not officially supported by Gravatar.

北京pk10 广东11选5走势图 江苏快三跨度走势图 天津十一选五前三走势 幸运时时彩 安徽快3走势 亿信彩票app 全民彩票 亿信彩票开奖 500彩票网