Pretend to have in the Django admin, 4 forms inlines, Each with a pair of 
fields choices, "Attributes" and "Value Option". We have the first pair, 
which initialize the field one with a value, for example color and other 
field you must have a queryset the choices.

<https://lh3.googleusercontent.com/-xTENLxQxmYk/VWSVhQRV9rI/AAAAAAAAAAM/Emk0LsNL778/s1600/Captura%2Bde%2Bpantalla%2B2015-05-26%2Ba%2Blas%2B10.11.25%2Ba.m..png>



















As you can see I need to filter each pair with their default values, if 
Color should show only white, black and blue.

    class ProductAttributeValueForm(forms.ModelForm):
        attribute = forms.ModelChoiceField(label=_('Attribute'),
            widget=forms.Select(attrs={'disabled': 'True'}),
            queryset=ProductAttribute.objects.all(), required=False)


    class ProductAttributeValueFormSet(BaseInlineFormSet):


        def __init__(self, *args, **kwargs):
            super(ProductAttributeValueFormSet, self).__init__(*args, **
kwargs)
            # This return initial [{'attribute' initial}, {..}, {..}]
            self.initial = [{'attribute': a} for a in obj.category.
attributes.all()]
            # Now we need to make a queryset to each field of each form 
inline
            self.queryset = [{'value_option' .. }, { .. }]

What I do is initialize each attribute with a value, for example, Color and 
passed a queryset to value_option with their respective values, white, blue 
and black.
I have tried to do this two days ago and I have not accomplished anything, 
not if the solution is on the forms or in any function of admin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd4344d1-68ec-4e62-82fa-88181294a40f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to