Skip to content

Instantly share code, notes, and snippets.

from django import template
from django.conf import settings
register = template.Library()
def absolutize_path(context, *args):
relative_url = ''.join(args)
absolute_paths = context.get('absolute_paths', False)
tadeo /
Last active Aug 15, 2018 — forked from treyhunner/
Enum for use with Django ChoiceField
from enum import Enum, EnumMeta
class ChoicesEnumMeta(EnumMeta):
def __iter__(self):
return ((, choice.value) for choice in super().__iter__())
class ChoicesEnum(Enum, metaclass=ChoicesEnumMeta):
def __str__(self):