**models.py**
class Person(models.Model):
name = models.CharField(max_length=200)
photo = EnhancedImageField(
upload_to="photos/%Y/%m/%d",
process_source = dict(
size='512x384', sharpen=True, upscale=True, format='JPEG'),
thumbnails = {
'avatar': dict(size='80x60'),
'medium': dict(size='256x192', detail=True),
}
)
**admin.py**
from django.contrib import admin
from django.contrib.admin.widgets import AdminFileWidget
from django import forms
from django.utils.safestring import mark_safe
from mysite import models
from mysite.models import Person
class AdminImageWidget(AdminFileWidget):
def render(self, name, value, attrs=None):
output = []
output.append('
' % \
(value.avatar.url, value.avatar.url))
output.append(super(AdminFileWidget, self).render(name, value, attrs))
return mark_safe(u''.join(output))
class PersonAdmin(admin.ModelAdmin):
formfield_overrides = {
models.EnhancedImageField: {'widget': AdminImageWidget},
}
admin.site.register(Person, PersonAdmin)