Просмотр исходного кода

Re-bind image formset if other product formsets fail to validate

We currently don't hold on to images that are uploaded if any of the
other formsets fail when editing/creating products. To prevent
issue #1126, we need to re-bind the formset.

This behaviour should be improved as part of #856.
master
Maik Hoepfel 12 лет назад
Родитель
Сommit
05c185fcfe
1 измененных файлов: 6 добавлений и 0 удалений
  1. 6
    0
      oscar/apps/dashboard/catalogue/views.py

+ 6
- 0
oscar/apps/dashboard/catalogue/views.py Просмотреть файл

@@ -267,6 +267,12 @@ class ProductCreateUpdateView(generic.UpdateView):
267 267
             if self.creating and form.is_valid():
268 268
                 self.object.delete()
269 269
                 self.object = None
270
+            # We currently don't hold on to images if the other formsets didn't
271
+            # validate. But as the browser won't re-POST any images, we can do
272
+            # no better than re-bind the image formset, which means the user
273
+            # will have to re-select the images (see #1126)
274
+            image_formset = self.image_formset(instance=self.object)
275
+
270 276
             return self.forms_invalid(
271 277
                 form, stockrecord_formset, category_formset,
272 278
                 image_formset, recommended_formset)

Загрузка…
Отмена
Сохранить