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("<option data-specie='%s' value='%s'> %s 
</option>"%(self.species.name, self.pk, self.name)) 

And then on the forms init:

class PetForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
        super(PetForm, self).__init__(*args, **kwargs)
        if 'instance' in kwargs:
            self.fields['breed'].label_from_instance = Option_with_specie

So now i customized the select field outputted by the foreing key, thanks 
to you Adi for finding just the right method to override.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to