Add additional options to Django form select widget

Viewed 30842

I have a form which I use to construct a queryeset filter. The form pulls in the project status options from the database. However, I wanted to add additional options, for example "All live promotions" ... so the select box would then look something like:

  • All Promotions *
  • All Live Promotions *
  • Draft
  • Submitted
  • Accepted
  • Reported
  • Checked
  • All Completed Promotions *
  • Closed
  • Canceled

Here the '*' are the ones I'd want to add and the others come from the database.

Is this possible?

class PromotionListFilterForm(forms.Form):
    promotion_type = forms.ModelChoiceField(label="Promotion Type", queryset=models.PromotionType.objects.all(), widget=forms.Select(attrs={'class':'selector'}))
    status = forms.ModelChoiceField(label="Status", queryset=models.WorkflowStatus.objects.all(), widget=forms.Select(attrs={'class':'selector'})) 
    ...
    retailer = forms.CharField(label="Retailer",widget=forms.TextInput(attrs={'class':'textbox'}))
1 Answers
Related