我只想要下面的一个模型实例。 如何在代码中强制执行此操作?
class Employer(models.Model):
name=models.CharField(max_length=50, verbose_name = "Employer's Name")
pin =models.CharField(max_length=50, verbose_name ="Employer's PIN")
def __unicode__(self):
return self.name
答案 0 :(得分:2)
试试这个:
class Employer(models.Model):
name = models.CharField(max_length=50, verbose_name="Employer's Name")
pin = models.CharField(max_length=50, verbose_name="Employer's PIN")
def __unicode__(self):
return self.name
class Meta:
unique_together = ('name', 'pin')