I have models like this:
class IdfPracownicy(models.Model):
nazwa = models.CharField(max_length=100)
class IdfPracaOpinie(models.Model):
nazwa = models.CharField(max_length=30)
class IdfPraca(models.Model):
numer_idf = models.ForeignKey(IdfPracownicy)
[...]
opinia = models.ForeignKey(IdfPracaOpinie)
uwagi = models.TextField()
data_wpisu = models.DateTimeField(auto_now=True)
I create my form like this:
class IdfPracaForm(forms.ModelForm):
numer_idf = forms.ModelChoiceField(queryset=IdfPracownicy.objects.all(), widget=forms.HiddenInput)
opinia = forms.ModelChoiceField(queryset=IdfPracaOpinie.objects.all(),empty_label=None)
class Meta:
# Nazwa modelu
model = IdfPraca
When I diplay this form in my browser, the <option>
tag shows an object instance like this:
<select name="opinia" id="id_opinia">
<option value="1">IdfPracaOpinie object</option>
<option value="2">IdfPracaOpinie object</option>
<option value="3">IdfPracaOpinie object</option>
<option value="4">IdfPracaOpinie object</option>
</select>
Instead of field "nazwa" values. What am I doing wrong?