用空格引用JSONField键

时间:2019-01-31 21:06:30

标签: postgresql django-admin python-3.6

我尝试使用admin.py
中的list_display引用键 Json的键名包含空格。

我收到此错误:

(admin.E108) The value of 'list_display[1]' refers to 'data__Service ID' , which is not a callable, an attribute of 'BotAdmin', or an attribute or method on 'myapp.Bot'

代码:

class Bot(models.Model):
    data = JSONField(default=dict, encoder=DjangoJSONEncoder)

class BotAdmin(admin.ModelAdmin):
    list_display = (
        'data__Title',
        'data__Service ID'
    )

0 个答案:

没有答案