Is it possible to change form field in Django models?

there is a form field 'sizes' is present in the model in a ManyToManyField
class AddForm(forms.ModelForm):
 quantity = forms.IntegerField(min_value=1, initial=1)

 class Meta:
 model = Product
 fields = (

 def __init__(self, *args, **kwargs):
 product_id = kwargs.pop('product_id', None)
 super(AddForm, self).__init__(*args, **kwargs)
 product = get_object_or_404(Product, id=product_id)
 self.fields['sizes'] = forms.ModelChoiceField(queryset=product.sizes.all())

how can I hide the field sizes when rendering the page and set it to a specific value,
self.fields['sizes'] = forms.BooleanField(initial=False, widget=forms.HiddenInput)

but in this case there is a hidden input where value="" ie empty request, although I also point out that initial=False
we need this in order to show the size field for items where it is not needed.
June 14th 19 at 20:53

Find more questions by tags Django