Why I cannot call my function (order_detail)in django admin file?

django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS: <class 'orders.admin.OrderAdmin'>: (admin.E108) The value of 'list_display[10]' refers to 'order_detail', which is not a callable, an attribute of 'OrderAdmin', or an attribute or method on 'orders.Order'.

System check identified 1 issue (0 silenced).

my django admin.py

def order_detail(obj):
    return '<a href="{}">View</a>'.format(reverse('orders:admin_order_detail',

order_detail.allow_tags = True

# @admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
    list_display = ['id', 'first_name', 'last_name', 'email',
                    'address', 'postal_code', 'city', 'paid', 'created', 'updated', 'order_detail']
    list_filter = ['paid', 'created', 'updated']
    inlines = [OrderItemInline]
    actions = [export_to_csv]

admin.site.register(Order, OrderAdmin)

You have to change 'order_detail' to order_detail.

Strings will be interpreted by django as attribute of the model or admin class. Specifying order_detail will inform django that it is a callable.

Back to Top