shabda
unread,Apr 15, 2008, 12:14:58 AM4/15/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
I have a form where I want to do something like,
class SetDefaultForm(forms.Form):
topics = forms.ModelChoiceField()
def __init__(self, user):
super(SetDefaultForm, self).__init__()
self.fields['topics'].queryset = Topic.objects.filter(user)
This does not work, of course, as ModelChoiceField has queryset as
required argument.
So I have to do something like,
class SetDefaultForm(forms.Form):
topics = forms.ChoiceField()
def __init__(self, user):
super(SetDefaultForm, self).__init__()
self.fields['topics'].choices= [topic for topic in
Topic.objects.filter(user)]
Is there a better way?