Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use TreeNodeChoiceField to render category field
Marcin Gębala9d09e6950a06
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 95e220530e..da1a589835 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -7,13 +7,15 @@ from django.forms.widgets import CheckboxSelectMultiplefrom django.utils.encoding import smart_textfrom django.utils.text import slugifyfrom django.utils.translation import pgettext_lazy+from mptt.forms import TreeNodeChoiceField-from . import ProductBulkActionfrom ...product.models import (- AttributeChoiceValue, Collection, Product, ProductAttribute, ProductImage,- ProductType, ProductVariant, Stock, StockLocation, VariantImage)+ AttributeChoiceValue, Category, Collection, Product, ProductAttribute,+ ProductImage, ProductType, ProductVariant, Stock, StockLocation,+ VariantImage)from ..widgets import RichTextEditorWidgetfrom .widgets import ImagePreviewWidget+from . import ProductBulkActionclass RichTextField(forms.CharField):@@ -134,7 +136,6 @@ class ProductTypeForm(forms.ModelForm):class ProductForm(forms.ModelForm):-class Meta:model = Productexclude = ['attributes', 'product_type', 'updated_at']@@ -152,6 +153,7 @@ class ProductForm(forms.ModelForm):'collections': pgettext_lazy('Add to collection select', 'Collections')}+ category = TreeNodeChoiceField(queryset=Category.objects.all())collections = forms.ModelMultipleChoiceField(required=False, queryset=Collection.objects.all())description = RichTextField()