Reputation: 15
I am doing a tutorial from HackedExistence and am getting the following error when trying to syncdb:
class Beer(models.Model):
^
SyntaxError: invalid syntax
I am running Django on a virtualenv
Code is as follows:
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
Upvotes: 0
Views: 359
Reputation: 169274
Choices should be defined in a list or tuple of two-tuples.
You've forgotten the end-bracket of your tuple.
BEER_CHOICES = (
('D', 'Domestic'),
('I', 'Import'),
) # <- missing end-bracket
Upvotes: 4