mirror of
https://github.com/django/django.git
synced 2024-11-29 22:56:46 +01:00
16 lines
394 B
Python
16 lines
394 B
Python
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(
|
|
models.Q(price__gt=models.F('discounted_price')),
|
|
'price_gt_discounted_price'
|
|
)
|
|
]
|