Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Initialize product category instead of excluding it
Marcin Gębala3e24ab7ba444
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex f605605952..c7bd23feb9 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -16,23 +16,22 @@ class ProductCategoryForm(forms.Form):class ProductForm(forms.ModelForm):class Meta:model = Product- exclude = ['category']fields = ['name', 'description', 'collection']def __init__(self, *args, **kwargs):super(ProductForm, self).__init__(*args, **kwargs)+ categories = Category.objects.all()+ self.fields['category'].choices = [(c.slug, c.name) for c in categories]class ShirtForm(ProductForm):class Meta:model = Shirt- exclude = ProductForm.Meta.excludeclass BagForm(ProductForm):class Meta:model = Bag- exclude = ProductForm.Meta.excludeProductImageFormSet = inlineformset_factory(Product, ProductImage, extra=1)diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex c8d5714f0e..467986d2ab 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -62,6 +62,10 @@ class ProductView(StaffMemberOnlyMixin, UpdateView):else:return super(ProductView, self).get_object(queryset)+ def get_initial(self):+ self.initial.update({'category': self.kwargs.get('category')})+ return self.initial.copy()+def get_form_class(self):if not self.variant_formset:variant_formset_cls = get_variant_formset(