Dynamic python Python Dashboard

Asked

Viewed 277 times

1

I am developing a project that requires a form to be created by the size of the amount of item that is created in another form. The initial form is the Formrota:

    class FormRota(forms.ModelForm):
        researcher =forms.ModelChoiceField(queryset=Profile.objects.all(), widget=forms.Select(attrs={'class':'form-control'}) )
   establishment=forms.ModelChoiceField(queryset=Establishment.objects.all(), widget=forms.Select(attrs={'class':'form-control'}))
        product_to_search = forms.ModelMultipleChoiceField(queryset=Product.objects.all(), widget=forms.CheckboxSelectMultiple(attrs={'class':'checkbox-inline'}))
        date = forms.DateField(label='Data do registro', widget=forms.DateInput(attrs={'class': 'form-control', 'placeholder': 'Data de entrada de dados'}))

Let the other form search you:

class FormSeach(forms.ModelForm):
    class Meta:
        model = Seach
        fields = ['rout', 'price_product']

the field price_product needs to be created by the size of the product_to_search who is in Formrota.

Can someone help me, how do I have fields dynamically created in the forms? The version I use is 1.3 of Django!

Grateful!

  • Are you developing from 0 or is it maintenance? Any particular reason to use Django 1.3?

  • It is an existing project, still to finish!

  • Got it. See if it’s worth updating the version of Django as well as the libs you use. If you have to maintain the project, it will be very old things.

  • If you want to create multiple forms from one value, read inlineformset_factory and modelformset_factory for the version of Django you are using. (That’s if I understand your case)

  • What I need is for a field to replicate how many times products_to_search has products. I need the rout field to remain static and be replaced by the others!

  • Carlos, have you managed to solve this problem? I’ve implemented something very similar. If you need just let me know and I’ll help you better.

  • Hello Antoniazzi, I could not, in fact I even sought other ways and met the need for such a moment, but I would like your help to solve this issue, it is very important!

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.