Freedom_Ben
Freedom_Ben

Reputation: 11953

Python: How to create a sequence of two-tuples

I am working with Django and I'm getting an error that I don't know how to fix. I'm sure this is a newbie problem. I have the following data structure that I thought would be "a sequence of two-tuples:"

CONFERENCES = (
    ( 'AE' 'AFC East' ),
    ( 'AN' 'AFC North' ),
    ( 'AS' 'AFC South' ),
    ( 'AW' 'AFC West' ),
    ( 'NE' 'NFC East' ),
    ( 'NN' 'NFC North' ),
    ( 'NS' 'NFC South' ),
    ( 'NW' 'NFC West' ),
)

This is referenced like this:

class Conference( models.Model ): 
    conference_name = models.CharField( max_length=2, choices=CONFERENCES ) 

However, Django is giving me this error after I run python manage.py validate:

gameTrackerApp.conference: "conference_name": "choices" should be a sequence of two-tuples.

What am I doing wrong?

Upvotes: 1

Views: 773

Answers (1)

zero323
zero323

Reputation: 330323

Missing commas:

CONFERENCES = (
   ( 'AE', 'AFC East' ),
   ( 'AN', 'AFC North' ),
   ( 'AS', 'AFC South' ),
   ( 'AW', 'AFC West' ),
   ( 'NE', 'NFC East' ),
   ( 'NN', 'NFC North' ),
   ( 'NS', 'NFC South' ),
   ( 'NW', 'NFC West' ),
)

Upvotes: 5

Related Questions