F
F
Fedor fedor2017-06-15 16:06:43
Django
Fedor fedor, 2017-06-15 16:06:43

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

1 answer(s)
A
Andrey Burov, 2017-06-15
@napmen

https://docs.djangoproject.com/en/dev/ref/models/o...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question