Answer the question
In order to leave comments, you need to log in
Is it possible to combine two CharField fields in models?
Is it possible to combine two fields through a slash and check for unique on it?
Let's say
class Factory(models.Model):
city = models.CharField('Город', max_length=30)
name = models.CharField('Наименование организации', max_length=50)
uniquetincity = city + '/' + tin(verbose_name='Город/ИНН', unique=True)
Answer the question
In order to leave comments, you need to log in
class Meta:
unique_together = ('city', 'tin')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question