Re: Show HTML in Labels for Model Choice Fields

2013-05-22 Thread Guillermo Siliceo
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

Re: Show HTML in Labels for Model Choice Fields

2011-01-02 Thread Adi
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

Show HTML in Labels for Model Choice Fields

2010-12-30 Thread Adi
Hi I have a situation like this class AppearanceThemesForm(forms.Form): page_theme = forms.ModelChoiceField(widget=forms.RadioSelect(attrs={'title':'Select the appropriate theme for your pages.'}), queryset=Theme.objects.filter(section="1"), initial=Theme.objects.get(section="1",representa