瀏覽代碼

add unique constraint on pages

davidmscholz 1 天之前
父節點
當前提交
d982913650
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      models/models.py

+ 3 - 0
models/models.py

@@ -16,3 +16,6 @@ class PageProductMapping(models.Model):
     # products that grant access to the page
     products = fields.Many2many('product.product', string='Alternative Products')
 
+    _sql_constraints = [
+        ('page_uniq', 'unique(page)', 'Each page can only be mapped once.'),
+    ]