Skip to content

Instantly share code, notes, and snippets.

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