2👍
✅
You can use template tags and filters anywhere in your Python code, just import them and use them:
from django.template.defaultfilters import safe
forms.RadioSelect(choices=[(o.choice_value, safe(o.choice_name))
for o in Choice.objects.filter()])
Source:stackexchange.com