views:

150

answers:

1

I'd like to have several fields in my form being rendered as ChoiceFields which get their content from the database.

I was thinking something like:

class SeriesForm(ModelForm):
  series = forms.ChoiceField(choices=Series.objects.all())

  class Meta:
    model = Series
    exclude = ('model', 'date_added',)

But the field series is now not appearing at all in my form. What am I missing? Thanks.

Update 2

series = forms.ModelChoiceField(queryset=Series.objects.values('series'), 
  empty_label="     ")
A: 

Use a ModelChoiceField instead.

Ignacio Vazquez-Abrams
Thanks it worked just fine.
Stephen
I've changed my code as above....and I have the same issue as before
Stephen