我正在做一个来自 HackedExistence 的教程,并且在尝试 syncdb 时收到以下错误:
class Beer(models.Model):
^
SyntaxError: invalid syntax
我在 virtualenv 上运行 Django
代码如下:
BEER_CHOICES = (
('D', 'Domestic'),
('I', 'Import'),
class Beer(models.Model):
name = models.CharField(max_length=200)
slug = models.Slugfield(unique=True)
brewery = models.foreignKey('Brewery')
locality = models.CharField(max_length=1, choice=BEER_CHOICES)
description = models.TextField(blank=True)
def __unicode__(self):
return self.name
class Brewery(models.Model):
name = models.CharField(max_length=200)
slug = models.Slugfield(unique=True)
description = models.TextField(blank=True)
def __unicode__(self):
return self.name