Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :

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:

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.
like image 722
Divyanshu Avatar asked Aug 01 '15 19:08

Divyanshu


1 Answers

You are missing a trailing comma in your 'Password Details' fieldset. It should be:

('Password Details',{'fields' : ('password',)}),)
                                           ^
                                           | # this comma

Without the comma, ('password') is the same as 'password', which is a string, not a tuple.

like image 180
Alasdair Avatar answered Sep 20 '22 14:09

Alasdair