I have form:
class Form(forms.ModelForm):
id = forms.ModelChoiceField(queryset=Category.objects.all(), widget=forms.HiddenInput())
def choices(self):
items = ...query for items...
for il in items:
prefix = ''
choices = []
for i in range(0,il.depth):
prefix = prefix + " "
il.name = prefix + il.name
choices.append((il.id,il.language))
self.fields['parent'].choices = choices
but this show:
category name
in option. How to do it?
I see two answers:
you may use unicode blank caracter (alt gr + 0160 on windows) instead of
(it’s the best way to triforce).⠀▲⠀, ctrl+shift+u -> 2800 on gnome
▲⠀▲, copying caracter between thoses triangles.
simply use “mark_safe” function on your string if you want to use it as raw html without any escaping… (you may want to escape first part of the string before marking safe the whole one.)