blob: 08fbe9e1df70b29d2aaaf7bf2a35bb70e516cdd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from django.db import models
class Product(models.Model):
name = models.CharField(max_length=255)
price = models.IntegerField()
discounted_price = models.IntegerField()
class Meta:
constraints = [
models.CheckConstraint(
check=models.Q(price__gt=models.F('discounted_price')),
name='price_gt_discounted_price',
),
]
|