g214/metadata/admin.py

48 lines
1.1 KiB
Python

# coding=utf-8
from django.contrib import admin
from .models import Metadata, Contact, Category, DataEntity, Tag, Navigation
class DataEntityInline(admin.StackedInline):
model = DataEntity
extra = 1
class MetadataAdmin(admin.ModelAdmin):
inlines = [DataEntityInline]
readonly_fields = ('image_img',)
list_display = ('id', 'image_img', 'title_cn', 'abstract', 'created', 'updated')
search_fields = ('title_cn', 'abstract')
list_per_page = 10
class ContactAdmin(admin.ModelAdmin):
list_display = ('name', 'mail', 'phone', 'created', 'updated')
list_per_page = 10
class CategoryAdmin(admin.ModelAdmin):
list_display = ('id', 'name')
list_per_page = 10
class TagAdmin(admin.ModelAdmin):
list_display = ('name', 'type')
list_per_page = 10
class NavigationAdmin(admin.ModelAdmin):
list_display = ('name', 'order_by', 'parent')
list_per_page = 10
admin.site.register(Metadata, MetadataAdmin)
admin.site.register(Contact, ContactAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Tag, TagAdmin)
admin.site.register(Navigation, NavigationAdmin)