I have a class in my forms and a object called tiposervico (ForeignKey). See bellow. In my template, after select a tiposervico I would like to display 'descricao' field on my screen. How can i do that?
class servicoForm(forms.ModelForm):
tiposervico = forms.ModelChoiceField(queryset=tiposervico.objects.all(), required=True)
tiposervico -> id, descricao
You can override the
label_from_instance
of thefield
inside theget_form()
method in CBV and get access to the field withlambda
For FBV, you can do so after initializing your form;