I have the following field in a django form:
position = forms.ModelChoiceField(Position.objects.order_by('-ordering'),
empty_label='Select Position',)
In my Position model, I am using the unicode field to display the field called “position”. However, in this particular form, I want the output to be a different field in the model called “position-select”. How would I do this without altering the default output of the unicode field?
Thank you.
Try “subclassing ModelChoiceField and override label_from_instance”, per the example at https://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield. You could specify a reference to the
__unicode__function of your other field within that overridden class.