예제 #1
0
 def test_deconstruction(self):
     constraint = models.Q(price__gt=models.F('discounted_price'))
     name = 'price_gt_discounted_price'
     check = models.CheckConstraint(constraint, name)
     path, args, kwargs = check.deconstruct()
     self.assertEqual(path, 'djmodels.db.models.CheckConstraint')
     self.assertEqual(args, ())
     self.assertEqual(kwargs, {'constraint': constraint, 'name': name})
예제 #2
0
 def test_repr(self):
     constraint = models.Q(price__gt=models.F('discounted_price'))
     name = 'price_gt_discounted_price'
     check = models.CheckConstraint(constraint, name)
     self.assertEqual(
         repr(check),
         "<CheckConstraint: constraint='{}' name='{}'>".format(
             constraint, name),
     )
예제 #3
0
 class Meta:
     constraints = [
         models.CheckConstraint(
             models.Q(price__gt=models.F('discounted_price')),
             'price_gt_discounted_price')
     ]
예제 #4
0
 class Meta:
     constraints = [
         models.CheckConstraint(models.Q(age__gte=18), 'is_adult')
     ]
예제 #5
0
파일: models.py 프로젝트: iMerica/dj-models
def today_callable_q():
    return models.Q(last_action__gte=datetime.datetime.today())
예제 #6
0
 def get_extra_descriptor_filter(self, instance):
     return models.Q(lang=get_language())