njpma/app/text/admin.py
2021-10-28 20:39:04 +05:30

32 lines
798 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']
search_fields = ['slug', 'title', 'byline']
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