我有这个模型:
class Address(models.Model):
street = models.CharField(blank=True, max_length=300, verbose_name='Straat')
house_number = models.CharField(blank=True, max_length=10, verbose_name='Huisnummer')
zipcode = models.CharField(blank=True, max_length=300, verbose_name='Postcode')
city = models.CharField(blank=True, max_length=300, verbose_name='Stad')
但是,对于使用此地址模型的某些模型,我希望空白=真为空白=假。如何在创建模型时指定它?这没有用:
class Address(models.Model):
blank = False
street = models.CharField(blank=blank, max_length=300, verbose_name='Straat')
house_number = models.CharField(blank=blank, max_length=10, verbose_name='Huisnummer')
zipcode = models.CharField(blank=blank, max_length=300, verbose_name='Postcode')
city = models.CharField(blank=blank, max_length=300, verbose_name='Stad')
#Create
Address(blank=True)