作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在为我创建的自定义用户编写自定义管理模型后出现此错误。这是用户管理的代码:
class MyUserAdmin(UserAdmin):
form = UserChangeForm
add_form=UserCreationForm
fieldsets = (
('Personal Details', {
'fields': (
'emp_id',
('emp_first_name', 'emp_last_name'),
('emp_gender', 'emp_dob', 'emp_marital_status'),
('emp_current_add','emp_permanent_add'),
('emp_email_id', 'emp_mobile'),
'emp_interests'
)}),
('Company Details', {
'fields': (
'emp_designation',
'emp_expertise',
('emp_desk_ph', 'emp_pcname', 'emp_current_location'),
('emp_comp_join_date', 'emp_account_join_date'),
('emp_farewell_date', 'emp_company_termination_date', 'emp_account_termination_date', 'emp_relocation_date'),
'is_active'
)}),
('Permission', {
'fields': (
('is_superuser','is_staff','is_admin'),
'groups'
)}),
('Password Details',{'fields' : ('password')}),)
运行 makemigrations
命令后,我得到这个错误:
SystemCheckError: System check identified some issues:
ERRORS: <class 'user.admin.MyUserAdmin'>: (admin.E008)
The value of 'fieldsets[1]['fields']' must be a list or tuple.
最佳答案
您在“密码详细信息”字段集中缺少尾随逗号。应该是:
('Password Details',{'fields' : ('password',)}),)
^
| # this comma
如果没有逗号,('password')
与 'password'
相同,都是字符串,而不是元组。
关于python - Django Admin 报错admin.E008 The value of fieldsets must be a list or tuple,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31765584/
我是一名优秀的程序员,十分优秀!