Hey Adi your answer saved me lots of work, but i want to elaborate on it, i
had this use case but i didnt have to subclass the field all i did was
defined a new label_from_instance
def Option_with_specie(self):
return mark_safe(" %s
"%(self.species.name, self.pk, self.name))
And then on t
I was able to find the solution to it myself.
The key was to
1. Create a custom field that extended ModelChoiceField.
2. Overwrite the label_from_instance method in the custom field.
3. Return a HTML string from the label_from_instance method, and
marking that as a safe_string.
from django.forms
2 matches
Mail list logo