class beer(models.Model):
tapStatus = models.CharField(max_length=1)
def __unicode__(self):
return self.tapStatus
beerdescription = models.CharField(max_length=400)
def __unicode__(self):
return self.beerdescription
beerStyle = models.CharField(max_length=5)
def __unicode__(self):
return self.beerStyle
beerabv = models.CharField(max_length=5)
def __unicode__(self):
return self.beerabv
beername = models.CharField(max_length=40)
def __unicode__(self):
return self.beername
答案 0 :(得分:3)
您可以使用BooleanField
。这是一个例子:
class beer(models.Model):
tapStatus = models.BooleanField(_('tap status'), default=False,
help_text=_('decide whether or not this item gets pasted onto the website'))
def __unicode__(self):
return str(self.tapStatus)
beerdescription = models.CharField(max_length=400)
def __unicode__(self):
return self.beerdescription
beerStyle = models.CharField(max_length=5)
def __unicode__(self):
return self.beerStyle
beerabv = models.CharField(max_length=5)
def __unicode__(self):
return self.beerabv
beername = models.CharField(max_length=40)
def __unicode__(self):
return self.beername
答案 1 :(得分:1)
你可能想要BooleanField
:
class BooleanField(**options) A true/false field. The default form widget for this field is a CheckboxInput. If you need to accept null values then use NullBooleanField instead.