[英]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. 我正在使用Django,但遇到了我不知道如何解决的错误。 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
: 但是,在我运行
python manage.py validate
之后,Django给了我这个错误:
gameTrackerApp.conference: "conference_name": "choices" should be a sequence of two-tuples.
What am I doing wrong? 我究竟做错了什么?
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' ),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.