[Django]-Define Django Model Constraints

3👍

You can add it in a Q object like so,

class Meta:
  order_with_respect_to = 'user_member'
  constraints = [
      models.CheckConstraint(check=~Q(project_member_id=project__project_creator_id) , 
         name='project creator not project member'),
  ]

Hope this helps!

👤devdob

Leave a comment