فهرست منبع

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.'),
+    ]