Here is how I accomplished this with a ModelForm

class VariationForm(forms.ModelForm):
    option_values =
forms.ModelMultipleChoiceField(queryset=Value.objects.none(),
widget=CheckboxSelectMultiple(), required=False)

    class Meta:
        model = Variation

    def __init__(self, *args, **kwargs):
        super(VariationForm, self).__init__(*args, **kwargs)
        if 'instance' in kwargs:
            self.fields['option_values'].queryset =
kwargs['instance'].product.values.all()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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