Skip to content

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

Collection form template, views

Pacu2514ce8e56621
diff --git a/saleor/dashboard/category/forms.py b/saleor/dashboard/category/forms.py
index d3817d5a23..a26b830540 100644
--- a/saleor/dashboard/category/forms.py
+++ b/saleor/dashboard/category/forms.py
@@ -5,7 +5,6 @@ from django.utils.translation import pgettext_lazy
from text_unidecode import unidecode
from ...product.models import Category
-from ..product.widgets import ImagePreviewWidget
class CategoryForm(forms.ModelForm):
diff --git a/saleor/dashboard/collection/forms.py b/saleor/dashboard/collection/forms.py
index 5c8f64a1a7..6e45229801 100644
--- a/saleor/dashboard/collection/forms.py
+++ b/saleor/dashboard/collection/forms.py
@@ -6,7 +6,6 @@ from text_unidecode import unidecode
from ...product.models import Collection, Product
from ..forms import AjaxSelect2MultipleChoiceField
-from ..product.widgets import ImagePreviewWidget
class CollectionForm(forms.ModelForm):
diff --git a/saleor/dashboard/collection/views.py b/saleor/dashboard/collection/views.py
index f886d82371..e0b1b5f4d3 100644
--- a/saleor/dashboard/collection/views.py
+++ b/saleor/dashboard/collection/views.py
@@ -36,7 +36,7 @@ def collection_create(request):
form = CollectionForm(
request.POST or None, request.FILES or None, instance=collection)
if form.is_valid():
- collection = form.save()
+ form.save()
msg = pgettext_lazy('Collection message', 'Added collection')
messages.success(request, msg)
return redirect('dashboard:collection-list')
diff --git a/templates/dashboard/collection/detail.html b/templates/dashboard/collection/detail.html
index e745af4746..206a705704 100644
--- a/templates/dashboard/collection/detail.html
+++ b/templates/dashboard/collection/detail.html
@@ -46,7 +46,7 @@
<div class="row">
<div class="col m12 l9">
<div class="card">
- <form method="post" id="form-collection" action="" novalidate>
+ <form method="post" id="form-collection" enctype="multipart/form-data" novalidate>
<div class="card-content card-content-form">
{% csrf_token %}
<div class="row">
@@ -60,15 +60,13 @@
</div>
</div>
<div class="card-action right-align">
+ <a href="{% url 'dashboard:collection-list' %}" class="btn btn-flat">
+ {% trans "Cancel" context "Collection secondary action" %}</a>
{% if collection.pk %}
- <a href="{% url 'dashboard:collection-list' %}" class="btn btn-flat">
- {% trans "Cancel" context "Collection secondary action" %}</a>
<button type="submit" class="btn btn-flat primary">
{% trans "Update" context "Collection detail action" %}
</button>
{% else %}
- <a href="{% url 'dashboard:collection-list' %}" class="btn btn-flat">
- {% trans "Cancel" context "Collection secondary action" %}</a>
<button type="submit" class="btn btn-flat primary">
{% trans "Create" context "Collection detail action" %}
</button>