I have 2 fields in my model class
class A(model.Model):
field1 = models.ImageField(upload_to='path', null=True)
field2 = models.URLField(null=True)
I need to unite so that if first field is full, second field can't be filled. And vice versa.
I try to create Meta class in class A with field unique_together:
class Meta:
unique_together = (field1, field2)
but in that case, both field can't be empty and both can be full. But I need that just 1 of fields must be full.
答案 0 :(得分:1)
Customize save() method in you A model:
EnableQuery