<commit_before>
from django.contrib import admin

from image_helper.fields import SizedImageField
from image_helper.widgets import AdminImagePreviewWidget

from pseudo_cms import models

class ContentAdmin(admin.ModelAdmin):
    list_display = ['thumbnail', 'url', 'title', 'page_title']
    search_fields = ['title', 'page_title', 'body', 'meta_description']
    exclude = ('body_html',)

    fieldsets = (
        ('', {
            'fields': ('url',)
        }),
        ('Search Engine Fields', {
            'fields': ('title', 'meta_description'),
        }),
        ('Page Content', {
            'fields': ('page_title', 'page_tagline', 'content_format', 'body', 'image'),
        })
    )

    def thumbnail(self, obj):
        """Thumbnail for list display preview"""
        thumbnail_url = obj.image.thumbnail.url()
        return '<img src="{0}" width="100" alt="thumbnail" />'.format(thumbnail_url)
    thumbnail.allow_tags = True

    formfield_overrides = {
        SizedImageField: {'widget': AdminImagePreviewWidget}
    }


admin.site.register(models.Content, ContentAdmin)<commit_msg>Bug Fix: Fixed broken admin page when content doesn't have image attached.<commit_after>
from django.contrib import admin

from image_helper.fields import SizedImageField
from image_helper.widgets import AdminImagePreviewWidget

from pseudo_cms import models

class ContentAdmin(admin.ModelAdmin):
    list_display = ['thumbnail', 'url', 'title', 'page_title']
    search_fields = ['title', 'page_title', 'body', 'meta_description']
    exclude = ('body_html',)

    fieldsets = (
        ('', {
            'fields': ('url',)
        }),
        ('Search Engine Fields', {
            'fields': ('title', 'meta_description'),
        }),
        ('Page Content', {
            'fields': ('page_title', 'page_tagline', 'content_format', 'body', 'image'),
        })
    )

    def thumbnail(self, obj):
        """Thumbnail for list display preview"""
        if obj.image:
            thumbnail_url = obj.image.thumbnail.url()
            return '<img src="{0}" width="100" alt="thumbnail" />'.format(thumbnail_url)
        else:
            return ''
    thumbnail.allow_tags = True

    formfield_overrides = {
        SizedImageField: {'widget': AdminImagePreviewWidget}
    }


admin.site.register(models.Content, ContentAdmin)
{'fraction_non_alphanumeric': 0.14120667522464697, 'fraction_numerical': 0.0034231921266581087, 'mean_word_length': 3.0379965457685665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2314994', 'n_tokens_mistral': 682, 'n_tokens_neox': 657, 'n_words': 158}