Skip to content

Instantly share code, notes, and snippets.

View absolutize_path.py
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 Aug 15, 2018 — forked from treyhunner/choice_enum.py
Enum for use with Django ChoiceField
View choices_enum.py
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):