简体   繁体   English

Django Admin错误admin.E008字段集的值必须是列表或元组

[英]Django Admin error admin.E008 The value of fieldsets must be a list or tuple

I am getting this error after writing a Custom Admin Model for the custom user I made. 为我创建的自定义用户编写自定义管理模型后,出现此错误。 Here's the code for User Admin : 这是User Admin的代码:

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')}),)

After running makemigrations command , i get this error: 运行makemigrations命令后,出现此错误:

SystemCheckError: System check identified some issues: SystemCheckError:系统检查确定了一些问题:

ERRORS: : (admin.E008) The value of 'fieldsets[1]['fields']' must be a list or tuple. 错误::(admin.E008)'fieldsets [1] ['fields']'的值必须是列表或元组。

Please help me out on this. 请帮助我。 Wasted a lot of time on this one. 在这个上浪费了很多时间。 Thanks in advance 提前致谢

You are missing a trailing comma in your 'Password Details' fieldset. 您在“密码详细信息”字段集中缺少结尾的逗号。 It should be: 它应该是:

        ('Password Details',{'fields' : ('password',)}),)

Without the comma, ('password') is the same as 'password' , which is a string not a tuple. 没有逗号, ('password')'password'相同,后者是字符串而不是元组。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django管理字段集上的FieldError - FieldError on django admin fieldsets 得到错误<class 'blog_app.admin.requestdemoadmin'> : (admin.E109) 'list_display[6]' 的值不能是 ManyToManyField</class> - Getting the error <class 'blog_app.admin.RequestDemoAdmin'>: (admin.E109) The value of 'list_display[6]' must not be a ManyToManyField 字段集在管理员 django 中没有任何作用 - Fieldsets don't do anything in admin django 为什么我的odering和list_view不能与django admin class中的fieldsets一起使用 - why can't my odering and list_view go together with fieldsets in django admin class Django 1.11 - 内联管理模型 - 错误:admin.E106 - Django 1.11 - Inline Admin Model - Error: admin.E106 为什么我收到“(admin.E003)&#39;raw_id_fields [N]&#39;的值必须是ForeignKey或ManyToManyField”的错误? - Why I am getting an “(admin.E003) The value of 'raw_id_fields[N]' must be a ForeignKey or ManyToManyField.” error in Django app? 使用 admin django 中的方法显示自定义字段集字段 - displaying custom fieldsets field using method in admin django Django Admin get_fieldsets无法与超宽类一起使用 - Django Admin get_fieldsets not working with classes extrapretty and wide Django 迁移错误:错误:“选择”必须是可迭代的(例如,列表或元组) - Django Migration Error: ERRORS: 'choices' must be an iterable (e.g., a list or tuple) 'fieldsets[4][1]' 的值必须是字典 - The value of 'fieldsets[4][1]' must be a dictionary
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM