ok I seem to have been able to make it work by passing in an extra
parameter in through the __init__  is this the best solution?? even
though it works it feels like i am doing something incorrect...

class AddMemberForm(forms.ModelForm):
    def __init__(self, obj, *args, **kwargs):
        super(AddMemberForm, self).__init__(*args, **kwargs)
        self.fields['member'].queryset =
Member.objects.filter(userprofile=obj)

    class Meta:
        model = ProductMember
        exclude = ('product')

On Apr 11, 12:29 am, Dan <[EMAIL PROTECTED]> wrote:
> Hi
>
> I am trying to create a ModelForm with a ModelChoiceField which has a
> should have a limited queryset that is filtered by the userprofile
> logged in, so far i have this:
>
> class AddMemberForm(forms.ModelForm):
>     member =
> forms.ModelChoiceField(Member.objects.filter(userprofile=userprofile))
>     class Meta:
>         model = ProductMember
>         exclude = ('product')
>
> How do I go about getting the 'userprofile' varible in to this class?
> Or is there some better other way to do this?
>
> Thanks in advance
>
> Dan
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to