> class TestForm(forms.ModelForm):
>     category = forms.ModelChoiceField(queryset=TestModel.objects.filter
> (filtercriterion__id=1))
>
>     class Meta:
>         model = TestModel
>
> In this example, TestModel.objects.filter(filtercriterion__id=1) will
> return a QuerySet of what I want to end up on the select list.  How
> can I send the numeral '1' as a variable to the TestForm class?

I found my own answer:

form = TestForm()
form.fields['category'].choices = TestModel.objects.\
            filter(filtercriterion__id=1).values_list('id','name')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to