0

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

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.