I have the following view
class ProductUpdateView(BaseProductUpdateView):
form_class = ProductForm
slug_field = "id"
def form_valid(self, form):
form.instance.hotel = form.cleaned_data["hotel"]
form.instance.parent = form.cleaned_data["parent"]
return super(ProductUpdateView, self).form_valid(form)
and following form:
class ProductForm(BaseProductForm):
hotel = forms.ModelChoiceField(queryset=Hotel.objects.all(), widget=forms.TextInput)
parent = forms.ModelChoiceField(queryset=Product.objects.all(), widget=forms.TextInput, required=False)
class Meta:
model = Product
exclude = ('slug', 'parent', 'hotel', 'status', 'score', 'product_class',
'recommended_products', 'related_products',
'product_options', 'attributes', 'categories')
When I save the form, form saved successfully. I can see the saved values of hotel and parent in admin, but when I re-open the update form page, other fields returns but hotel and parent fields return blank. Any ideas?