python - Django-值错误: too many values to unpack (expected 2)

标签 python django

我尝试使用模型创建下拉列表。

USER_TYPE = {
'admin': "Admin",
'patient': "Patient",
'helper': "Helper",
'therapist': "Therapist",
}


class User(AbstractBaseUser):
    user_type = models.CharField(max_length=10, choices=USER_TYPE, default="patient")

但是,我收到此错误:

ValueError: too many values to unpack (expected 2)

提前致谢!

最佳答案

您所需要的只是元组而不是字典。喜欢:

YEAR_IN_SCHOOL_CHOICES = ( ('FR', '新生'), ('所以','大二'), ('JR', '初级'), ('SR','高级'), )

关于python - Django-值错误: too many values to unpack (expected 2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47704137/

相关文章:

python - django-background-tasks 缺少数据库表

django - Django REST Framework-将额外的参数传递给 Action

linux - 如何使用 Apache 自动启动 Django Celery?

django {% if user.groups == 'FC' %} 不起作用

python - SleekXMPP 随意发送消息并仍然监听传入的消息。

python - 从 django admin 提供图像文件

python - Python 中的拱形关系信息图

python - 设置 IPython Notebook 内联图背景不透明

python - 访问 pyunittearDown 中的测试状态

python - 选项卡错误: inconsistent use of tabs and spaces in indentation - Integration MailChimp Django