我正在使用Django,我收到一个错误,我不知道如何修复。我确定这是一个新手问题。我有以下数据结构,我认为这将是“一个两元组的序列:”
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' ),
)
这是这样引用的:
class Conference( models.Model ):
conference_name = models.CharField( max_length=2, choices=CONFERENCES )
但是,运行python manage.py validate
后,Django正在给我这个错误:
gameTrackerApp.conference: "conference_name": "choices" should be a sequence of two-tuples.
我做错了什么?
答案 0 :(得分:5)
缺少逗号:
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' ),
)