我试着用模型制作一个水滴。在
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)
提前谢谢!在
您使用的是CharField,但是如果您想要下拉列表,则应该使用ChoiceField
您将用户类型作为字典提供,但是
所以尝试一下:
你只需要元组而不是字典。比如:
在学校的选择=( ('FR','Freshman'), ('SO','大二'), ('JR','Junior'), ('SR','Senior'), )在
相关问题 更多 >
编程相关推荐