phantasma/app/text/admin.py

32 lines
751 B
Python

from django.contrib import admin
from django.db.models import JSONField
from . import models
from ..widgets import PrettyJSONWidget
@admin.decorators.register(models.Text)
class TextAdmin(admin.ModelAdmin):
formfield_overrides = {
JSONField: {'widget': PrettyJSONWidget}
}
list_display = (
'__str__',
'item',
'edit',
'language',
'slug',
'public',
'position',
)
list_editable = ['public', 'language', 'position']
list_filter = ['language', 'public']
def item(self, obj):
return obj.data.get('item')
def edit(self, obj):
return obj.data.get('edit')
#@admin.decorators.register(models.Page)
#class PageAdmin(admin.ModelAdmin):
# pass