from django.contrib import admin from sorl.thumbnail.admin import AdminImageMixin from preview_admin import PreviewAdmin from news.models import News from utils import render_creole class NewsAdmin(AdminImageMixin, PreviewAdmin): prepopulated_fields = {'slug': ('title',)} list_display = ('title', 'date_created', 'date_updated') list_filter = ('author',) search_fields = ['title', 'content'] preview_fields = { 'content': render_creole } date_hierarchy = 'date_updated' def save_model(self, request, obj, form, change): if not obj.id: obj.author = request.user obj.save() admin.site.register(News, NewsAdmin)