Commit 26749bfa authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt

add random templatetag

parent d8679826
import os
import html
import json
import os
import random
import bleach as python_bleach
......@@ -42,6 +43,14 @@ def get(d, *args):
return d
@register.simple_tag(name='random')
def random_item(_list):
try:
return random.choice(_list)
except IndexError:
return None
@register.filter
def filename(value, include_ext=True):
base = os.path.basename(getattr(value, 'name', value))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment