Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Update CollectionForm to handle slug field

Mira Szewczyk5a0116378b69
diff --git a/saleor/dashboard/collection/forms.py b/saleor/dashboard/collection/forms.py
index 1d3e28bde7..f4307cf72d 100644
--- a/saleor/dashboard/collection/forms.py
+++ b/saleor/dashboard/collection/forms.py
@@ -1,8 +1,17 @@
+from unidecode import unidecode
+
from django import forms
+from django.utils.text import slugify
+
from ...product.models import Collection
class CollectionForm(forms.ModelForm):
class Meta:
model = Collection
- exclude = []
+ exclude = ['slug']
+
+ def save(self, commit=True):
+ self.instance.slug = slugify(unidecode(self.instance.name))
+ super(CollectionForm, self).save(commit=commit)
+ return self.instance