Skip to content

Instantly share code, notes, and snippets.

@umutcoskun
Created August 30, 2017 08:00
Show Gist options
  • Save umutcoskun/c825a44004fbf4c3a66452910ca8f9ee to your computer and use it in GitHub Desktop.
Save umutcoskun/c825a44004fbf4c3a66452910ca8f9ee to your computer and use it in GitHub Desktop.
Django custom template filter to hashing value.
from django import template
register = template.Library()
@register.filter(name='md5')
def md5(value):
"""
Usage:
{{ user.email|md5 }}
"""
import hashlib
return hashlib.md5(value).hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment