소스 검색

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