Skip to content

Instantly share code, notes, and snippets.

View Pettles's full-sized avatar

Pettles

  • Australia
View GitHub Profile
@goldhand
goldhand / staticencoder.py
Last active May 17, 2022 21:00
Django template tag for encoding images in base64 and rendering with server
from django import template
from django.contrib.staticfiles.finders import find as find_static_file
from django.conf import settings
register = template.Library()
@register.simple_tag
def encode_static(path, encoding='base64', file_type='image'):
"""