class ProductForm forms ModelForm class Meta model Product exclude use

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
class ProductForm(forms.ModelForm):
class Meta:
model = Product
exclude = ('user', 'record_status')
def __init__(self, user, *args, **kwargs):
super(ProductForm, self).__init__(*args, **kwargs)
self.user = user
def save(self):
instance = forms.save_instance(Product(user=user), self)
return instance