나는 모델이 있습니다 unique_together(a,b, max_occurences=3)
제약은 위의 모델에 추가 할 수처럼 (각 쌍 c
의 최대 3 개 값이 될 수 있습니다 (그래서 내가 뭔가를 필요로 지금unique_together (max_occurences = 3)와 같은 것이 있습니까?
class MyModel(models.Model):
a = models.IntegerField()
b = models.IntegerField()
c = models.IntegerField()
을 A, B) 이상적으로는 c
의 3 가지 값은 주어진 (a, b)에 대해 고유해야하지만, 무엇을 찾아야할지 모르며 (심지어 이와 같은 것이 MySQL에도 존재하는 경우). 이런 것이 있습니까, 아니면 다음과 같이해야합니다 :
class MyModel(models.Model):
a = models.IntegerField()
b = models.IntegerField()
c1 = models.IntegerField()
c2 = models.IntegerField()
c3 = models.IntegerField()
class Meta:
unique_together = ('a', 'b')
- 핸들 c1..c3 자신?
데이터를 더 잘 모델링해야합니다. –
나는 그것을 고려한다 - 지금 무엇? –