Reputation: 41513
Hay, say i have 2 models listing and category.
How would i use djangos form framework to automatically create a select drop down box for category?
class NewListingForm(forms.Form):
name = forms.CharField(required=True)
description = forms.CharField(widget=forms.Textarea, required=True)
category ...
Upvotes: 0
Views: 2463
Reputation: 25966
category = forms.ModelChoiceField(queryset=Category.objects.all(),
empty_label="(Nothing)")
Upvotes: 6