Django Common or not so common Errors and solitons

How to solve (admin.E107) The value of 'list_display' must be a list or tuple in Django

Today, we're going to solve one of the Django admin issues, which is:

(admin.E107) The value of 'list_display' must be a list or tuple.


This issue happens when you try to set something except list or tuple for list_display.


For example:



@admin.register(Topics)

class EcoProductAdmin(admin.ModelAdmin):

    list_display = "title"


Output:


<class 'core.admin.EcoProductAdmin'>: (admin.E107) The value of 'list_display' must be a list or tuple.

As I said, to solve this issue, we must set a tuple or list.


List:


@admin.register(Topics)

class EcoProductAdmin(admin.ModelAdmin):

    list_display = ['title']


Tuple:


@admin.register(Topics)

class EcoProductAdmin(admin.ModelAdmin):

    list_display = ('title',)


Note: you must add a comma when you want to display one item.


 python3 manage.py migrate --run-syncdb



 

Comments

Popular posts from this blog

Cheatsheet

Django SQL Drivers