尝试在模型字段上设置选项时出错。代码如下:
TICKET = 'TICKET',
TICKET_HISTORY = 'TH'
TICKET_RATE = 'TR'
PASSWORD_CHANGE = 'PASS'
CONTENT = 'CN'
TYPE_CHOICES = [
(TICKET, 'Ticket created'), (TICKET_HISTORY, 'Ticket changed'), (TICKET_RATE, 'Ticket rated'),
(PASSWORD_CHANGE, 'Password changed'), (CONTENT, 'Added content')
]
type = models.CharField(max_length=6, choices=TYPE_CHOICES, default=TICKET)
类型的选择似乎是正确的,不明白它的问题在哪里
例外情况:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f8acad18bf8>
Traceback (most recent call last):
File "/home/userwoozer/work/tickets/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/userwoozer/work/tickets/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/home/userwoozer/work/tickets/env/lib/python3.6/site-packages/django/core/management/base.py", line 425, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
main.Activity.type: (fields.E005) 'choices' must be an iterable containing (actual value, human readable name) tuples.
目前没有回答
相关问题 更多 >
编程相关推荐