mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #11964 -- Added support for database check constraints.
This commit is contained in:
15
tests/constraints/models.py
Normal file
15
tests/constraints/models.py
Normal file
@@ -0,0 +1,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(
|
||||
models.Q(price__gt=models.F('discounted_price')),
|
||||
'price_gt_discounted_price'
|
||||
)
|
||||
]
|
||||
Reference in New Issue
Block a user