Answer the question
In order to leave comments, you need to log in
How to check the uniqueness of two fields at the same time?
Good afternoon!
Tell me how to do a simultaneous check of the uniqueness of two fields
in my case: vlaninfo_vlan and vlaninfo_complex
example: add the following
1-1 - unique
1-2 - unique
2-1 - unique
2-2 - unique
further when adding field 1-1 it would give an error that this field combination is already in use
class VlanInfo(models.Model):
class Meta():
db_table = 'vlaninfo'
vlaninfo_vlan = models.IntegerField(blank=True, null=True, verbose_name='VLAN ID', default=1) # VLAN
vlaninfo_complex = models.ForeignKey(Complex)
vlaninfo_address = models.CharField(max_length=50, blank=True, verbose_name='VLAN INFO') # VLAN INFO
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question