浏览代码

Merge pull request #264 from tangentlabs/product-form-no-parent-validation

Fix product form validation when the parent field is excluded
master
David Winterbottom 13 年前
父节点
当前提交
d521b2e4be
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3
    1
      oscar/apps/dashboard/catalogue/forms.py

+ 3
- 1
oscar/apps/dashboard/catalogue/forms.py 查看文件

@@ -187,7 +187,9 @@ class ProductForm(forms.ModelForm):
187 187
 
188 188
     def clean(self):
189 189
         data = self.cleaned_data
190
-        if data['parent'] is None and not data['title']:
190
+        if 'parent' not in data and not data['title']:
191
+            raise forms.ValidationError(_("This field is required"))
192
+        elif 'parent' in data and data['parent'] is None and not data['title']:
191 193
             raise forms.ValidationError(_("Parent products must have a title"))
192 194
         return data
193 195
 

正在加载...
取消
保存